$datas = $collection->getSelect()->join(array('B' => $table), 'main_table.entity_id = B.parent_id', array());
当我尝试使用时:
$datas->getCollection();
或:
$datas->getData();
我收到此错误:
Fatal error: Uncaught exception 'Zend_Db_Select_Exception' with message 'Unrecognized method 'getData()'' in
如何在使用“join”后使用addFieldToFilter()?
答案 0 :(得分:1)
因为您将Zend DB语句的结果分配给$datas
变量,这将使其成为Zend_Db_Select
的实例而不是集合。
您应该通过引用进行更改,而不是将其分配给您的变量。
$collection->getSelect()->join(...
然后继续使用$collection
:
foreach ($collection as $entity) {
print_r($entity->getData());
}