我想在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
我该怎么做?