我的控制器
$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);
}
在我看来我有这条线
<?php foreach($recent as $as): ?> <?php echo $as['Calllog']['mobileNo'];?>
但是没有显示任何错误
我调试结果,我得到一行意味着工作正常 我也转储sql查询,其中查询运行正常,当我在phpmyadmin运行此查询时,它给了我一行,这是我想要的..但为什么它不回应我的视图页面上的结果
调试结果
array(
(int) 0 => array(
'CallLog' => array(
'idCallLog =>'3',
'mobileNo'=>'12345'
'User_id'=>'1'
)))
然后经过4行
array()
答案 0 :(得分:0)
试试这个
$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);