querybuilder查询在symfony2中定义参数

时间:2016-01-13 14:11:38

标签: symfony doctrine-orm selectquerybuilder

当我在给定的部分中定义一个参数时,它会给我一个错误,即这个" tt"参数是undefine。我不知道是什么问题。它给了我这个错误

注意:未定义的属性:Doctrine \ ORM \ QueryBuilder :: $ SELECT u1.unitid,m1.id FROM ApiMapBundle:Mappaths m1 INNER JOIN ApiMapBundle:Unitids u1 WITH m1.refUnitids2 = u1.id OR m1.refUnitids1 = u1。 id WHERE m1.id =:tt

             $cn=2;
            $qb = $em->createQueryBuilder();

            $query = $qb->select('u1.unitid','m1.id')
                    ->from('ApiMapBundle:Mappaths', 'm1')
                    ->join('ApiMapBundle:Unitids', 'u1', 'WITH', $qb->expr()->orX('m1.refUnitids2 = u1.id', 'm1.refUnitids1 = u1.id'))
                    ->andWhere('m1.id=:tt')
                     ->$qb->setParameter('tt', $cn)
                    ->getQuery()

                    ->getResult();
           return $query;

任何想法?

1 个答案:

答案 0 :(得分:0)

尝试从->$qb

中删除->$qb->setParameter('tt', $cn)