2013-05-08 95 views
1

我想设置两个参数$type$superior在我的查询生成器设置在查询生成器的symfony

$qb->select('a') 
    ->from('xxxBundle:entity', 'a') 
    ->where('a.typepro = :type') 
    ->andwhere('a.superior=: superior') 
    ->setParameter('type', $type) 
    ->setParameter ('superior',$superior); 

两个参数,但我没能得到相应的结果,我也得到了以下异常:

参数格式无效,:给定,但:或?预期。

任何想法?

回答

2

之间有一个空格 ':' 和你的参数名:

->andwhere('a.superior=: superior') 

相反,它应该是:

->andwhere('a.superior = :superior')