my controller
$data= $this->Contact->find('all',array(
'conditions' => array('Contact.User_id' => $id)));
$this->loadModel('Calllog');
foreach($data as $row){
$mobile= $row['Contact']['mobileNo'];
$home= $row['Contact']['homeNo'];
$work= $row['Contact']['workNo'];
$recent=$this->Calllog->find('all',
array('order'=>'Calllog.idCallLog DESC',
'limit' => 1,
'conditions' => array('Calllog.mobileNo' => array($mobile,$work,$home ),
'Calllog.User_id' => $id
)));
debug($recent);
$this->set('recent',$recent);
}
in my view i have this line
<?php foreach($recent as $as): ?> <?php echo $as['Calllog']['mobileNo'];?>
but isn't displaying anything even not any error
i debug the result in which i am getting one row means working fine and i have also dump sql query in which query is running fine and when i run this query in phpmyadmin it is giving me the one row which is what i want .. but why it is not echoing the result on my view page
debug result
array(
(int) 0 => array(
'CallLog' => array(
'idCallLog =>'3',
'mobileNo'=>'12345'
'User_id'=>'1'
)))
and then after 4 lines
array()
Try this
$data= $this->Contact->find('all',array(
'conditions' => array('Contact.User_id' => $id)));
$recent = array();
$this->loadModel('Calllog');
foreach($data as $row){
$mobile= $row['Contact']['mobileNo'];
$home= $row['Contact']['homeNo'];
$work= $row['Contact']['workNo'];
$recent[]=$this->Calllog->find('all',
array('order'=>'Calllog.idCallLog DESC',
'limit' => 1,
'conditions' => array('Calllog.mobileNo' => array($mobile,$work,$home ),
'Calllog.User_id' => $id
)));
}
$this->set('recent',$recent);
debug($recent);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.