我失去了trilion小時谷歌這但沒有一個解決方案是好的。Symfony2 Doctrine querybuilder其中IN
我有這樣的QueryBuilder:
$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)
;
我可以做第二個查詢,然後做類似$qb->getDQL()
但將我緩存查詢?
錯誤:
Invalid parameter number: number of bound variables does not match number of tokens
OMG,我感覺如此愚蠢...當然用戶!我沒有注意到它...是的array_values幫助!現在終於幻想工作$ arrayFolloweeIds = implode(「','」,$ arrayFolloweeIds)以及...我希望人們會發現它。謝謝 ! – EnchanterIO 2013-04-27 18:08:46
'array_values'也幫助了我。但爲什麼?我正在使用索引數組。另一方面,使用刪除查詢,它不使用'array_values'。我正在使用doctrine/orm v2.5.4 – alpham8 2017-11-22 13:42:42
我認爲這個問題是由數組上的亂序數字索引或可能具有字符串數字索引引起的。不是100%確定,但如果這就是爲什麼array_values工作的原因,因爲它給了你一個新的數組適當索引 – 2017-11-22 19:43:45