Matt McCormick
Matt McCormick

Reputation: 13190

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

Upvotes: 5

Views: 13163

Answers (1)

deceze
deceze

Reputation: 522005

$this->User->find('all', array('conditions' => array('id' => array(1, 5, 7))));

Upvotes: 13

Related Questions