我有一个类别的数组, 如何在使用Doctrine的类中使用IN语句?
答案 0 :(得分:-1)
你可以这样使用
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;
}
}