In fact, you can probably make a simpler request, depending on how you made your annotations.
Sort of:
$qb = $this->_em->createQueryBuilder() ->select('s') ->from('WallBundle:Status','st') ->innerJoin('st.like','l') ->where('l.user = :user') ->setParameter('user', $user) ->getQuery() ->getResult();
This should do the same, shorter and easier to understand, since there is only one request.
Update: I had the same problem as today and resolved it by putting two setParameters
in the second request. And so I found another way to solve it!
I did something like that:
$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() ;
source share