试图获得用户喜欢的状态。
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();
}
错误:无效的参数号:绑定变量的数量与标记的数量不匹配
顺便说一句:当我转储 $qb->getDQL() 时:
string 'SELECT s.id FROM TB\WBundle\Entity\Likes l LEFT JOIN l.status s WHERE l.user = :user' (length=87)
BTW2:当我将 '$qb->getDQL()' 替换为 (12073) (状态 ID)时,它可以工作......