I have an array of category, how to use IN statement in where class using Doctrine?
Asked
Active
Viewed 78 times
0
-
1This question has already an answer [here](http://stackoverflow.com/a/6319643/1607098) – Touki Oct 07 '13 at 13:01
1 Answers
-1
You can use like this
public function searchCategory($target){//$target is an aray(1,2,3)
$query = $this->getEntityManager()
->createQuery("SELECT abc ct.target as target FROM AdminBundle:ClothingType ct WHERE ct.target IN (:target)")
->setParameter('target',$target['target']);// You can change it as ur requirment
try {
return $query->getResult();
} catch (\Doctrine\ORM\NoResultException $e) {
return null;
}
}

Suresh Kumar Amrani
- 935
- 9
- 18
-
-1. The code you posted contains both DQL syntax error and a PHP notice. Please, take time to read and test the code you provide. – Touki Oct 07 '13 at 13:05
-