【发布时间】:2023-03-18 07:20:01
【问题描述】:
我有两个模型:“画廊”和“图像”。当我尝试从 gallery_controller 获取图像时,我看到了这个错误:
注意(8):未定义变量:images [APP\controllers\galleries_controller.php,第 25 行]
我使用 CakePHP 的 find 方法来限制图像结果。
这是我的画廊控制器:
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 行吗? -
$this->set('images', $images);在第 25 行
标签: php cakephp-1.3