脚本宝典收集整理的这篇文章主要介绍了php – symfony2 doctrine expr子查询:错误:参数号无效,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
public function getLikedstatuses(User $user) { $qb = $this->_em->createQueryBuilder(); $qb ->select('s.id') ->From('WallBundle:Likes','l') ->innerJoin('l.status','s') ->where('l.user = :user') ->setParameter('user',$user) ->orderBy('s.id','DESC') ; $qb2= $this->_em->createQueryBuilder() ->select('st') ->from('WallBundle:Status','st'); $qb2 ->andWhere($qb2->exPR()->in('st.id',$qb->getDQL())); return $qb2->getQuery()->getResult(); }
BTW:当我转储$qb-> getDQL()时:
string 'SELECT s.id FROM TB\WBundle\EntITy\Likes l LEFT JOIN l.status s WHERE l.user = :user' (length=87)
BTW2:当我为'(12073)(状态的id)替换’$qb-> getDQL()’时,它的工作原理……
就像是 :
$qb = $this->_em->createQueryBuilder() ->select('s') ->from('WallBundle:Status','st') ->innerJoin('st.like','l') ->where('l.user = :user') ->setParameter('user',$user) ->getQuery() ->getResult();
更新:我遇到了与今天完全相同的问题,并通过将两个setParameters放在第二个查询中来解决它.因此我找到了解决它的另一种方法!
我做了类似的事情:
$qb = $this->_em->createQueryBuilder() ->select('s.id') ->from('WallBundle:Likes','l') ->innerJoin('l.status','s') ->where('l.user = :user') ->orderBy('s.id','DESC') ->getDQL() ; $qb2= $this->_em->createQueryBuilder() ->select('st') ->from('WallBundle:Status','st'); ->where('st.like in('.$qb.')') ->setParameter('user',$user) ->getQuery() ;
以上是脚本宝典为你收集整理的php – symfony2 doctrine expr子查询:错误:参数号无效全部内容,希望文章能够帮你解决php – symfony2 doctrine expr子查询:错误:参数号无效所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。