设置在查询生成器的symfony
问题描述:
我想设置两个参数$type
和$superior
在我的查询生成器设置在查询生成器的symfony
$qb->select('a')
->from('xxxBundle:entity', 'a')
->where('a.typepro = :type')
->andwhere('a.superior=: superior')
->setParameter('type', $type)
->setParameter ('superior',$superior);
两个参数,但我没能得到相应的结果,我也得到了以下异常:
参数格式无效,:给定,但:或?预期。
任何想法?
答
之间有一个空格 ':' 和你的参数名:
->andwhere('a.superior=: superior')
相反,它应该是:
->andwhere('a.superior = :superior')