1

谁能告诉我?

我如何在 magento 中编写这种类型的查询(打开多个条件)

SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
LEFT JOIN Orders
ON (Customers.CustomerID=Orders.CustomerID and Orders.status = 1)

//我知道这种类型

$collection = Mage::getModel('module/model_name')->getCollection();
$collection->getSelect()->join( array('table_alias'=>$this->getTable('module/table_name')), 'main_table.foreign_id = table_alias.primary_key', array('table_alias.*'));

如何在 JOIN 中添加多个条件?

4

1 回答 1

3

我自己找到了答案,结果很容易

$collection = Mage::getModel('module/model_name')->getCollection();
$collection->getSelect()->join( array('table_alias'=>$this->getTable('module/table_name')), 'main_table.foreign_id = table_alias.primary_key and table_alias.columnname = ".."' , array('table_alias.*'));
于 2013-07-01T17:47:35.660 回答