Doctrine在哪里与Doctrine_Query [英] Doctrine where in with Doctrine_Query
问题描述
可以做:
$q->createQuery('q')
->whereIn('q.id', $q2)
其中$ q2是其他Doctrine_Query对象。因为我的子查询是复杂的,我不想在SQL中写入...
Where $q2 is an other Doctrine_Query object. Because my subquery is complex and I don't want to write it in SQL...
推荐答案
不幸的是,一个href =http://www.doctrine-project.org/api/orm/1.2/doctrine/doctrine_query_abstract.html#whereIn%28%29 =nofollow> Doctrine API文档,你可以不要将另一个查询对象传递给 whereIn()
,因此您必须事先获取ID并将其传递到数组中。不过请注意,因为如果您传递一个空数组,那么对于这些ID,将会有 NO FILTERING 。换句话说:它将返回表中存在的所有行,而不是none。
Unfortunately, according to the Doctrine API documentation, you can't pass another query object to whereIn()
, so you will have to fetch your ID-s beforehand and pass them in an array. Be careful though, because if you pass an empty array, then there will be NO FILTERING for those ID-s. In other words: it will return all rows present in your table, instead of none.
这篇关于Doctrine在哪里与Doctrine_Query的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!