How to use the in statement in DQL in Doctrine 2.0

后端 未结 4 1995
暖寄归人
暖寄归人 2020-12-17 08:37

I have the following query that uses an IN statement.

$ids = array(1,2,3);
$query = \'select o from Organisation o where o.id in (:ids)\';
$this->_entityM         


        
4条回答
  •  悲哀的现实
    2020-12-17 09:11

    I solved this:

    $con = $this->getEntityManager();
    $query = $con->createQuery("SELECT cl
                                FROM BackendBundle:classifieds cl 
                                INNER JOIN BackendBundle:locations lo WITH cl.locationId = lo.id
                                INNER JOIN BackendBundle:municipality mu WITH lo.municipalId = mu.id
                                WHERE cl.verified = false AND mu.id = ".$munId." AND cl.locationId NOT IN (:ids) ");
    $query->setParameters(array('ids' => $locsIds));
    return $query->getResult();
    

提交回复
热议问题