Blo*_*kas 20 doctrine dql query-builder
我失去了trilion时间谷歌,但没有一个解决方案是好的.
我有这个查询构建器:
$qb2=$this->createQueryBuilder('s')
->addSelect('u')
->innerJoin('s.user','u')
->where("u.id IN(:followeeIds)")
->andWhere('s.admin_status = false')
->setParameter('user', $user)
->setParameter('followeeIds', $arrayFolloweeIds)
->orderBy('s.id','DESC')
->setMaxResults(15)
;
Run Code Online (Sandbox Code Playgroud)
我可以做第二个查询然后做,$qb->getDQL()但我会缓存查询?
错误:
Invalid parameter number: number of bound variables does not match number of tokens
Run Code Online (Sandbox Code Playgroud)
Gha*_*iss 58
您正在设置用户参数,但我没有看到它在任何地方的查询中使用?
我也有问题WHERE IN和Doctrine QueryBuilder与数组会给我一个类似的错误,奇怪的是,array_values在绑定参数之前运行似乎也解决了这些问题.
尝试:
$qb2=$this->createQueryBuilder('s')
->addSelect('u')
->innerJoin('s.user','u')
->where("u.id IN(:followeeIds)")
->andWhere('s.admin_status = false')
->setParameter('followeeIds', array_values($arrayFolloweeIds))
->orderBy('s.id','DESC')
->setMaxResults(15)
;
Run Code Online (Sandbox Code Playgroud)
在 Symfony2.8 中,以下示例对我有帮助
...
$qb2->where(
$qb2->expr()->in('u.id', ':ids')
)
->setParameter('ids', $ids_array)
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
48602 次 |
| 最近记录: |