Ok my dear friends today my aim is to have another MVC with you.
In previous lessons we passed the data between controller and view.
This time I will use model view and controller that is all in MVC to run a simple application..
First i will create the controller and save it in C:\wamp\www\yii\myyii\protected\controllers or in your controller directory as PaymentController.php
Here is my controller source code..
<?php
class PaymentController extends Controller{
function actionDetail(){
//$content['all']=date('d/m/y');
//$this->render('Detail',array('content'=>$content));
$model=new date;//Here I create new object.
$content['all']=$model->getAll();//Here we call the getAll method in model and assign it to an array.
$this->render('Detail',array('content'=>$content));
}
}
?>
Now I need the model...below is my model and save it is date.php im model directory.[C:\wamp\www\yii\myyii\protected\models]
Here is the source code of model...
<?php
class date extends CFormModel{
public function getAll(){
$a=date('d/m/y');
return $a;
}
}
?>
Now I need the view.....
Here is my view and save it in C:\wamp\www\yii\myyii\protected\views directory inside a folder called Payment as Detail.php
<?php
//echo("The payment should be give in the form of cash or credit/debit card");
foreach ($content as $data){
echo($data);
}
?>
Now all is over...
Type below in address bar and have the output.
http://localhost/yii/myyii/index.php?r=Payment/Detail
Be happy.........
In previous lessons we passed the data between controller and view.
This time I will use model view and controller that is all in MVC to run a simple application..
First i will create the controller and save it in C:\wamp\www\yii\myyii\protected\controllers or in your controller directory as PaymentController.php
Here is my controller source code..
<?php
class PaymentController extends Controller{
function actionDetail(){
//$content['all']=date('d/m/y');
//$this->render('Detail',array('content'=>$content));
$model=new date;//Here I create new object.
$content['all']=$model->getAll();//Here we call the getAll method in model and assign it to an array.
$this->render('Detail',array('content'=>$content));
}
}
?>
Now I need the model...below is my model and save it is date.php im model directory.[C:\wamp\www\yii\myyii\protected\models]
Here is the source code of model...
<?php
class date extends CFormModel{
public function getAll(){
$a=date('d/m/y');
return $a;
}
}
?>
Now I need the view.....
Here is my view and save it in C:\wamp\www\yii\myyii\protected\views directory inside a folder called Payment as Detail.php
<?php
//echo("The payment should be give in the form of cash or credit/debit card");
foreach ($content as $data){
echo($data);
}
?>
Now all is over...
Type below in address bar and have the output.
http://localhost/yii/myyii/index.php?r=Payment/Detail
Be happy.........