使用doctrine中的wherenotIn子句和其他查询

时间:2014-11-24 10:59:32

标签: symfony doctrine-orm

我想在doctrine

中使用where in子句

我是这样做的:

$q->select('u.id')
->add('from', $from)
->Join('Entities\User','u','with','evt_vstr.user = u.id')
->where('evt_vstr.event = ?1')
->andwhere('u.designation= ?2')
->andwhere('u.id notIN (SELECT sender FROM Entities\Connect)')
ORTHIS  ->andwhereNotIn('i.id',$connect_id)  
->setParameter(1,$content['event_id'])
->setParameter(2,$content['designation'])
->setFirstResult($i)
->setMaxResults($max_result);

但它引发了一个错误:

PHP Fatal error:  Uncaught exception 'Doctrine\\ORM\\Query\\QueryException' with message 'SELECT u.id FROM Entities\\EventVisitor evt_vstr INNER JOIN Entities\\User u WITH evt_vstr.user = u.id WHERE evt_vstr.event = ?1 AND u.designation= ?2 AND u.id notIN ('SELECT sender FROM Entities\\Connect')'

当我写下这个

->andwhereNotIn('u.id', array(1,2,3,4,5)')

然后它会出现以下错误

PHP Fatal error:  Call to undefined method Doctrine\\ORM\\QueryBuilder::andwhereNotIn()

我在这里阅读:doctrine how to write WhereIn() with another sql query inside

我该怎么做?

sjagrYann Eugoné

0 个答案:

没有答案