我有方法findByTag()
,该方法应返回带有%#i%
的实体,但不会。这是dql构建的sql:
SELECT p0_.id AS id_0, p0_.content AS content_1, p0_.date AS date_2, p0_.user_id AS user_id_3 FROM post p0_ INNER JOIN user u1_ ON p0_.user_id = u1_.id LEFT JOIN points p2_ ON p0_.id = p2_.post_id LEFT JOIN comments c3_ ON p0_.id = c3_.post_id WHERE p0_.content LIKE '%#i%' ORDER BY p0_.date DESC LIMIT 20
如果我将其输入到mysql中,它将返回确定。
有人有主意吗?
$dql = $this->createQueryBuilder('p')
->innerJoin('p.user', 'c')
->leftJoin('p.points', 'pp')
->leftJoin('p.comments', 'cc')
->Where('p.content LIKE \'%#i%\'')
->setMaxResults($max)
->orderBy('p.date','DESC');
$dql->getQuery()
->getResult();
return $dql;
答案 0 :(得分:0)
尝试
$dql = $this->createQueryBuilder()
->from('YourBundleName:YourEntityName', 'p')
->innerJoin('YourBundleName.user', 'c')
->leftJoin('YourBundleName.points', 'pp')
->leftJoin('YourBundleName.comments', 'cc')
->Where('p.content LIKE \'%#i%\'')
->setMaxResults($max)
->orderBy('p.date','DESC');
return $dql->getQuery()->getResult();