0
我的画廊模式是关系到我的图像模型,但是当我retrive从galleries_controller我看不到任何结果,而是看这个错误图片:CakePHP中查找相关数据
警告(二):提供对的foreach无效参数()[APP \视图\画廊\ view.ctp 35行]
这里是从我的控制器操作的代码:
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid gallery', true));
$this->redirect(array('action' => 'index'));
}
$this->set('gallery', $this->Gallery->read(null,$id));
$this->Gallery->Image->find('all',array('conditions' => array('Image.gallery_id'=> $id)));
$this->set('images', $images);
}
这是循环我在我的画廊/视图迭代通过阵列。
<?php
$i = 0;
foreach ($images['Image'] as $image):
$class = null;
if ($i++ % 2 == 0) {
$class = ' class="altrow"';
}
?>
<tr<?php echo $class;?>>
<td><?php $image['id'] ;?></td>
<td><?php echo $image['name'];?></td>
<!--<td><?php echo $image['img_file'];?></td>-->
<td><?php echo $html->image('uploads' . DS . 'images' . DS . $image['img_file'], array('alt' => 'Gallery Image')); ?></td>
</tr>
<?php endforeach; ?>
谢谢swiecki它的工作 – user1080247 2012-01-11 09:03:02