Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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);
like image 578
Matt McCormick Avatar asked Jan 18 '12 07:01

Matt McCormick


1 Answers

$this->User->find('all', array('conditions' => array('id' => array(1, 5, 7))));
like image 51
deceze Avatar answered Nov 16 '22 06:11

deceze