Reputation: 3038
How do I programatically create a Doctrine ORM call for the following SQL when I have a different number of values in the 'OR' clause on each run?
SELECT * FROM table1
WHERE table1.group = 1 OR 2 OR 3
Specifically, I may only want to get table1.group values of 1 OR 2 next time
Upvotes: 0
Views: 51
Reputation: 4304
Your values can be in array. Sample repository method:
public function findAllInGroupList(Array $groupList)
{
$em = $this->getEntityManager();
$queryText = "SELECT a FROM AcmeBundle:Acme a ";
$queryText .= "WHERE a.group IN (:groupList)";
$query = $em->createQuery($queryText);
$query->setParameter('groupList', $groups);
return $query->getResult();
}
Upvotes: 1