Thanks for your reply alirz23. Would you chose the first one because of the MVC concept or for another reason?
Here is what I need to do:
Extract the list of customers who are residing in a hotel on any particular day so that I may choose only from this list when I create orders for the restaurant of the hotel. So this is my code which I include in actionCreate:
public function actionCreate()
{
$model=new Order1;
$model->date= date('d-m-Y');
// building $data to display only current customers in view
list($d, $m, $y) = explode('-', date('d-m-Y'));
$mk=mktime(0, 0, 0, $m, $d, $y);
$date = date ('Y-m-d', $mk);
$data =Reservation::model()->findAll('arrival<=:id && departure>=:id',array(':id'=> $date));
.....
......
......
$this->render('create',array(
'model'=>$model,
'data'=>$data,
));
}
What if I create a public function like this in my controller:
public function listclient()
{ list($d, $m, $y) = explode('-', date('d-m-Y'));
$mk=mktime(0, 0, 0, $m, $d, $y);
$date = date ('Y-m-d', $mk);
$data =Reservation::model()->findAll('arrival<=:id && departure>=:id',array(':id'=> $date));
return $data;
}
And then in my create view, I call the method:
<?php $clients = $this->listclient(); ?>