语法错误:第0行,第81列:错误:预期文字,得到'NULL'

时间:2014-02-06 14:54:38

标签: symfony doctrine-orm query-builder

当我尝试通过查询构建器执行查询时出现错误[Syntax Error] line 0, col 81: Error: Expected Literal, got 'NULL'

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

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

r.lang字段定义为:

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

请帮助解决错误

1 个答案:

答案 0 :(得分:12)

检查NULL值时,表达式应为

->andWhere('r.lang IS NULL')