2015-10-21 49 views
1

KOMPLEX标准过滤器得到了查询:使学说

$criteria = new \Doctrine\Common\Collections\Criteria(); 
     $criteria 
      ->where($criteria->expr()->eq('collection', $post['id'])) 
      ->andWhere($criteria->expr()->eq('path', '')) 
      ->orWhere($criteria->expr()->eq('path', '/')); 

这确实喜欢

where collecion = 1 and path = '' or path = '/' 

但如何查询说:

where collecion = 1 and (path = '' or path = '/') 

铜n00n

回答

1

试试这个:

$criteria = new \Doctrine\Common\Collections\Criteria(); 
    $criteria 
     ->where($criteria->expr()->eq('collection', $post['id'])) 
     ->andWhere(
      $criteria->expr()->orX(
       $criteria->expr()->eq('path', ''), 
       $criteria->expr()->eq('path', '/') 
      ) 

     ); 

希望得到这个帮助