我试图在doctrine查询中检索一个布尔值。我可以在doctrine查询中成功检索String值,但是在我的Entity类中添加一个变量名的boolean参数我得到了一个错误
[Syntax Error] line 0, col 111: Error: Expected end of string, got '1'
完整的学说片段
$results = $this->getDoctrine()->getRepository('RealBundle:Cats')
->createQueryBuilder('q')
->addSelect('ABS(q.pts) AS HIDDEN pointsOrder')
->orderBy('pointsOrder', 'DESC')
->orderBy('active', TRUE) //code fails at this point
->getQuery()
->getResult();
请问我能做什么?
答案 0 :(得分:1)
尝试改为:
$results = $this->getDoctrine()->getRepository('RealBundle:Cats')
->createQueryBuilder('q')
->addSelect('ABS(q.pts) AS HIDDEN pointsOrder')
->addOrderBy('pointsOrder', 'DESC')
->addOrderBy('active', 'ASC') //code fails at this point
->getQuery()
->getResult();
您需要使用addOrderBy
来使用多个订单,addOrderBy
的第二个参数需要ASC
或DESC
,它不能TRUE