How to find multiple values for Cake PHP find() method? (IN condition)

Matt McCormick picture Matt McCormick · Jan 18, 2012 · Viewed 12.9k times · Source

Is there a way to do a find() in CakePHP that converts to an IN condition? It seems the find() methods just take a single value to search on.

I would like to do something like this:

$this->User->findAllById(array(1, 5, 7));

which would convert the SQL to something like:

SELECT * FROM users WHERE id IN (1, 5, 7);

Answer

deceze picture deceze · Jan 18, 2012
$this->User->find('all', array('conditions' => array('id' => array(1, 5, 7))));