0

我有一个类别数组,如何在使用 Doctrine 的 where 类中使用 IN 语句?

4

1 回答 1

-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;
                }

}

于 2013-10-07T13:01:56.860 回答