2015-10-21 70 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', '/') 
      ) 

     ); 

希望得到這個幫助