nowiko
nowiko

Reputation: 2567

QueryBuilder in Symfony 2

I want to select all rows from table where filed not empty. I try do this:

 $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;

But getting only empty array. Where is my problem?

Upvotes: 0

Views: 60

Answers (1)

jamek
jamek

Reputation: 812

Change line:

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

to:

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

Upvotes: 1

Related Questions