【发布时间】:2018-04-15 23:14:52
【问题描述】:
如果我在主表中加入的表有 2 行和 1 个父 ID,我如何在 Magento 的 _preparecollection 中执行 Select 语句。
我现在有的桌子。
表 2(sales_flat_invoice_comment)
我目前的准备收藏
$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->getSelect()->join( array('a'=> mgmx_sales_flat_invoice_comment), 'a.parent_id = main_table.entity_id', array('a.comment'));
$this->setCollection($collection);
return parent::_prepareCollection();
这个查询,在回显中会是这样的
选择
main_table.*、a.comment发件人mgmx_sales_flat_invoice_grid发件人main_table内连接mgmx_sales_flat_invoice_commentASaON a.parent_id = main_table.entity_id
但如果此查询在表 2 中找到超过 1 行,则会返回错误。
我想要的是像下面这样的东西
与 |作为分隔符。
如何在 Magento 的 _prepareCollection 中实现这一点。
【问题讨论】:
标签: php mysql magento join zend-framework