문제

I have the following code to load a custom collection:

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();

This produces the following SQL Query:

SELECT `main_table`.* FROM `despatchqueues` AS `main_table` 
WHERE (((can_sync = 1) or (is_synced = 0)))

How do I change my addFieldToFilter so that the resulting query will look like this:

SELECT `main_table`.* FROM `despatchqueues` AS `main_table` 
WHERE (((can_sync = 1) and (is_synced = 0)))
도움이 되었습니까?

해결책

try like this

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

Hope this helps!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top