My Sql is Below :

SELECT `main_table`.* FROM `tab` AS `main_table` WHERE (`main_table`.`list_id` = '36') AND (`active` = '1') AND (`start_datetime` <= '2017-02-14 09:13:58')  OR main_table.debug = 1

I know use by

$collection->addFieldToFilter('list_id', 36)
       ->addFieldToFilter('start_datetime', '2017-02-14 09:13:58')

to equivalent WHERE (main_table.list_id = '36') AND (active = '1') AND (start_datetime <= '2017-02-14 09:13:58')

But How can I do to equivalent

      OR main_table.debug = 1

If you are looking for SQL query equivalent to your collection with filter then printLogQuery function will work for you.

 $collection->addFieldToFilter('list_id', 36)
   ->addFieldToFilter('start_datetime', '2017-02-14 09:13:58');

$collection->printLogQuery(true); OR $collection->getSelect()->__toString();

Above code will give you the complete SQL query equivalent to your collection

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.