request with multiple id Symfony2 Doctrine
You can also get it directly from repository:
$em->getRepository('YourRepo')->findById(array(1,2,3,4,5));
Also you can pass parameters in get no tin array, but in simple string glued by commas
?ids=1,2,3,4,56
And after that get it from $request
$em->getRepository('YourRepo')->findById(explode(',', $request->get('ids'));
How about using the QueryBuilder class:
$qb = $em->createQueryBuilder();
$qb->select('m');
$qb->from('MyEntity', 'm');
$qb->where($qb->expr()->in('m.id', array(12, 10)));
//ArrayCollection
$result = $qb->getQuery()->getResult();
Or DQL:
$query = $em->createQuery('SELECT m FROM MyTable m WHERE m.id IN(12, 10)');