Symfony2 Doctrine Expr 'IS NOT NULL'
You can use isNotNull
:
'query_builder' => function ($er){
$qb = $er->createQueryBuilder('p');
$qb
->where($qb->expr()->andx(
$qb->expr()->in('p', '?1'),
$qb->expr()->isNotNull('p.location')
))
->setParameter(1, $this->totalScope);
return $qb;
},
You can also use DQL in your queryBuilder, which is much less ugly IMO.
Quick and dirty example from a controller:
$repo = $this->getDoctrine()->getRepository('AcmeBundle:Transaction');
$query = $repo->createQueryBuilder('t')
->where('t.timestamp > :timestamp')
->andWhere('t.pinNumber IS NOT NULL')
->setParameter('timestamp', new \DateTime('1 day ago'))
->getQuery()
;
Easier to read in my estimation.