Doctrine findBy with OR condition

ArVan picture ArVan · Feb 13, 2012 · Viewed 72.9k times · Source

Is it possible to use OR statement in Doctrine findBy() method? I know that given array is interpreted as case1 AND case2... Like this

$this->repos['notif']->findBy(array('status' => 1, 'status' => 2, 'status' => 3);

Stands for

SELECT * FROM `notif` WHERE status=1 AND status=2 AND status=3;

Now I need something to stand for:

SELECT * FROM `notif` WHERE status=1 OR status=2 OR status=3;

Is there a way to get all cases?

Answer

user3012985 picture user3012985 · Nov 20, 2013

You can write:

$this->repos['notif']->findBy(array('status' => array(1, 2, 3)));

and that should work too.