我有两个模型:'画廊'和'图像'。当我尝试从galleries_controller获取图像我看到这个错误:如何解决PHP中的“未定义变量”通知?
Notice (8): Undefined variable: images [APP\controllers\galleries_controller.php, line 25]
我使用CakePHP的find
方法来限制在图片搜索结果。
这里是我的galleries_controller:
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid image', true));
$this->redirect(array('action' => 'index'));
}
$this->set('gallery', $this->Galley->read(null, $id));
/// this code have some problem ///
$this->loadModel('image');
$Images= $this->Image->find('all',
array(
'limit' => 2, //int
)
);
$this->set('images', $images);
}
'$ this-> loadModel('image');'是25行吗? – 2012-01-07 01:53:17
$ this-> set('images',$ images);在行25 – user1080247 2012-01-07 01:54:34