Symfony 2中的QueryBuilder

时间:2014-10-30 13:17:20

标签: php symfony query-builder

我想从表中选择所有不是空的行。我试着这样做:

 $qb = $this->getDoctrine()->getManager()->createQueryBuilder();
    $qb->select('p')
        ->from('\Vputi\UserBundle\Entity\Profile', 'p')
        ->where('p.driverLicence != :literal')
       ->setParameter('literal', null);

 var_dump($qb->getQuery()->getResult());die;

但只获得空阵列。我的问题在哪里?

1 个答案:

答案 0 :(得分:1)

更改行:

->where('p.driverLicence != :literal')

到:

->where('p.driverLicence is not NULL')