Doctrine subqueries: number of bound variables does not match
$qb = $this->_em->createQueryBuilder() ->select('s.id') ->from('WallBundle:Likes','l') ->innerJoin('l.status', 's') ->where('l.user = :user') ->orderBy('s.id','DESC') ->setParameter('user', $user) ->getDQL(); $qb2= $this->_em->createQueryBuilder() ->select('st') ->from('WallBundle:Status','st'); ->where('st.like IN('.$qb.')') ->getQuery();
Doctrine gives an Error: Invalid parameter number: number of bound variables does not match number of tokens.
Solution:
$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();
Can someone explain me why the parameters need to be setted in the subquery?











