Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql Magento addFieldToFilter on collection-如何获取AND where子句_Sql_Magento - Fatal编程技术网

Sql Magento addFieldToFilter on collection-如何获取AND where子句

Sql Magento addFieldToFilter on collection-如何获取AND where子句,sql,magento,Sql,Magento,我有以下代码来加载自定义集合: echo Mage::getModel("ibi/despatchqueues") ->getCollection() ->addFieldToFilter( array( 'can_sync', 'is_synced' ), array( array('eq' => 1), // can_sync = 1 array('eq' => 0), // i

我有以下代码来加载自定义集合:

echo Mage::getModel("ibi/despatchqueues")
->getCollection()
->addFieldToFilter(
    array(
        'can_sync',
        'is_synced'
    ),
    array(
        array('eq' => 1), // can_sync  = 1
        array('eq' => 0), // is_synced = 0
    )
)
->getSelect();
这将生成以下SQL查询:

SELECT `main_table`.* FROM `despatchqueues` AS `main_table` 
WHERE (((can_sync = 1) or (is_synced = 0)))
如何更改我的
addFieldToFilter
,使生成的查询如下所示:

SELECT `main_table`.* FROM `despatchqueues` AS `main_table` 
WHERE (((can_sync = 1) and (is_synced = 0)))
像这样试试

 echo Mage::getModel("ibi/despatchqueues")
->getCollection()
->addFieldToFilter('can_sync', array('eq' => 1))
->addFieldToFilter('is_synced', array('eq' => 0))
->getSelect();
希望这有帮助

像这样试试看

 echo Mage::getModel("ibi/despatchqueues")
->getCollection()
->addFieldToFilter('can_sync', array('eq' => 1))
->addFieldToFilter('is_synced', array('eq' => 0))
->getSelect();

希望这有帮助

哦,我明白了。当存在多个过滤器时,每个
addFieldToFilter
充当
。谢谢你。哦,我明白了。当存在多个过滤器时,每个
addFieldToFilter
充当
。谢谢你。