Zoha Ali Khan
Zoha Ali Khan

Reputation: 1699

Symfony2 Query Builder

I am trying to get records from a table where patentgroup_id is null. I tried this

$repository = $this->getDoctrine()->getRepository('MunichInnovationGroupPatentBundle:SvPatents');
$qb1 = $repository->createQueryBuilder('sv')
    ->select('sv')
    ->where('sv.patentgroup = :patentgroup')
    ->setParameter('patentgroup', null)
    ->getQuery();
    $nogroup_patents = $qb1->getArrayResult();
   var_dump($nogroup_patents);

There is one record in the table whose patentgroup_id is null but I am getting empty array.

Any ideas? What I am doing wrong

thanks

Upvotes: 0

Views: 3600

Answers (1)

MDrollette
MDrollette

Reputation: 6927

same way you would do it in SQL

->where('sv.patentgroup IS NULL')

Upvotes: 1

Related Questions