Zend_Db_Select帮助加入

时间:2011-05-02 22:42:58

标签: mysql zend-framework join zend-db-select

我正在使用以下代码并收到以下错误

$select = $model->select();
$select->from(array('stocktakejob'), 
            array("ProductID" => "stocktakejob.ProductID",
                    "TotalCount" => "SUM(stocktakejob.NewCount)"
              )
       )->join(array('products'),
               'products.ProductID = stocktakejob.ProductID', 
               array("ProductCode" => "products.ProductCode")
       )->where("stocktakejob.StockTakeID = ".$stocktake->getStockTakeID())
       ->group('stocktakejob.ProductID');

错误:异常

Select query cannot join with another table

有什么我想念的吗?任何帮助都会受到赞赏。

1 个答案:

答案 0 :(得分:3)

我认为你在制作连接语句时应该将完整性检查设置为false:

$select->setIntegrityCheck(false);