我的 PurchaseController 中有这个功能。
public function viewAction()
{
$detail = new Application_Model_Dbtable_Purchasedetails();
$purchaseid = $this->getRequest()->getParam('purchaseid');
$select = $detail->select()
->from(array('c' => 'purchasedetails'))
->join(array('p' => 'product'), 'p.productid = c.productid')
->where('purchaseid = ?', $purchaseid)
->setIntegrityCheck(false);
$fetch = $detail->fetchAll($select);
$this->view->purchase = $fetch;
}
我的 view.phtml 中有这段代码
foreach($this->view as $fetch) :?>
<tr>
<td><?php echo $this->escape($detail['productid']);?></td>
<td><?php echo $this->escape($detail['name']);?></td>
<td><?php echo $this->escape($detail['quantity']);?></td>
<td><?php echo $this->escape($detail['price']);?></td>
<td><?php echo $this->escape($detail['price']*$detail['quantity']);?> </td>
</tr>
但是,我收到此错误消息。
Warning: Invalid argument supplied for foreach() in
这个错误的原因和解决方法是什么?非常感谢。