Syntax Error: line 0, col 81: Error: Expected Literal, got 'NULL'
Asked Answered
I

1

9

I got an error [Syntax Error] line 0, col 81: Error: Expected Literal, got 'NULL' when I try to execute query via query builder

        $qb = $this->createQueryBuilder('r')
            ->select('r')
            ->where('r.query = :query')
            ->setParameter('query', $query)   
            ->andWhere('r.lang = NULL')
        ;

        return $qb->getQuery()->getOneOrNullResult();

r.lang field is defined as:

/**
 * @var integer
 *
 * @ORM\ManyToOne(targetEntity="\BW\LocalizationBundle\Entity\Lang")
 * @ORM\JoinColumn(name="lang_id", referencedColumnName="id")
 */
private $lang;

Help to solve error, please

Interfluve answered 6/2, 2014 at 14:54 Comment(0)
B
26

When you check for NULL value the expression should be

->andWhere('r.lang IS NULL')
Boren answered 6/2, 2014 at 14:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.