这是一个使用Expr()类的示例-
我几天前也需要这样做,花了一些时间来找出确切的语法和用法:
public function findProductsExpensiveThan($price){ $em = $this->getEntityManager(); $qb = $em->createQueryBuilder(); $q = $qb->select(array('p'))->from('YourProductBundle:Product', 'p')->where( $qb->expr()->gt('p.price', $price))->orderBy('p.price', 'DESC')->getQuery(); return $q->getResult();}


