Symfony 2学说错误

时间:2013-11-07 14:43:28

标签: symfony doctrine

我想算一下来自乌克兰的用户,但我有错误。

[Semantical Error] line 0, col 192 near 'Ukraine GROUP': Error: 'Ukraine' is not defined.
500 Internal Server Error - QueryException

我如何理解问题在于我如何输入乌克兰价值。

public function Action(){
    $em = $this->getDoctrine()->getEntityManager();

    $qb = $em->createQueryBuilder();        
    $qb->add('select', 'count(user.id) as recount, ur.country, ur.year, ur.month, ur.day')  
        ->add('from','CobaCoreBundle:User ur')
        ->add('where', $qb->expr()->andx(
            'ur.date <= :end',
            'ur.date >= :start',
            'ur.country = Ukraine'
        ))
        ->setParameter('start',$period['fromd'])
        ->setParameter('end', $period['tod']);
    $qb->add('groupBy','ur.year, ur.month, ur.day');


}

1 个答案:

答案 0 :(得分:2)

字面值应括在语音标记中:

'ur.country = "Ukraine"'