MySQL’s “IN” query filter is very useful. Basically, if you have a list of record ID numbers, you can query them all neatly like so:
$query="SELECT field_name,field_name FROM table_name WHERE id IN (3,7,11,13,17)"
The containing comma-delimited list is a simple and neat query that can be assembled in your code quickly.
Duplicating MySQL’s “IN( )” in Doctrine is just as easy, you just have to give the “findBy” method an array based on the pattern:
array(field(s)=>array(id_val,id_val,id_val…) )
Here’s a basic example to help illustrate:
$resultsArr= $em->getRepository('repositoryName')->findBy(array('id' => array(1, 2, 3)));
I thought it was too easy, thanks to Stack Overflow for showing me the way!