我在 Magento 查询中使用 OR 过滤器时遇到问题。这是我用的:
$collection = Mage::getModel('sales/order')->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter(
array(
array('attribute'=>'status','eq'=>'pending'),
array('attribute'=>'created_at', 'from'=>$startDate, 'to'=>$finishDate)
)
);
我想要以下 WHERE 语句:WHERE 'status' = 'pending' OR (created_at < $startDate AND created_at > $finishDate)
但我收到以下错误消息
Fatal error: Uncaught exception 'Mage_Core_Exception' with message 'Cannot determine the field name.' in /home/content/r/o/n/ronakkaria/html/magento/app/Mage.php:563
Stack trace:
#0 /home/content/r/o/n/ronakkaria/html/magento/app/code/core/Mage/Sales/Model/Resource/Collection/Abstract.php(52): Mage::throwException('Cannot determin...')
#1 /home/content/r/o/n/ronakkaria/html/magento/app/code/core/Mage/Sales/Model/Resource/Collection/Abstract.php(80): Mage_Sales_Model_Resource_Collection_Abstract->_attributeToField(Array)
#2 /home/content/r/o/n/ronakkaria/html/new/admin/magentoInvoice/getInvocieList.php(43): Mage_Sales_Model_Resource_Collection_Abstract->addAttributeToFilter(Array)
#3 {main} thrown in /home/content/r/o/n/ronakkaria/html/magento/app/Mage.php on line 563
我目前使用的是 1.6-2rc 版本。