我正在尝试添加一个网格,我需要在其中进行左连接。
protected function _prepareCollection()
{
$collection = Mage::getResourceModel('admin/user_collection')->join("school/school",'ref_id = referer_id',"school_name",**"left"**);
var_dump((string)$collection->getSelect());
$this->setCollection($collection);
return parent::_prepareCollection();
}
即使我在看到它显示的转储时已经定义了“left”:
SELECT main_table
。*,school/school
。school_name
FROM admin_user
AS main_table
INNER JOIN school
AS school/school
ON ref_id = referer_id
我试着去做
$collection = Mage::getResourceModel('admin/user_collection')->**joinLeft**("school/school",'ref_id = referer_id',"school_name","left");
但我的系统没有向我显示任何var_dump挂起。
答案 0 :(得分:7)
在getSelect()
join
答案 1 :(得分:0)
如果要将属性
放置或条件,请使用产品集合$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToFilter(
array(
array('attribute'=>'my_attribute', 'eq'=>'0'),
array('attribute'=>'my_other_attribute', 'neq'=>'0')
),
'',
'left'
);