I\'m refactoring a Zend Framework 2 application to use doctrine 2.5 DBAL instead of Zend_DB (ZF1). I have the following Zend_Db query:
$subS
Selected answer is over-complicated and the second one is wrong (it won't return anything is the condition is totally fullfilled, meaning if there is no row at all returned by the sub-query).
But yes, you can refactor to use IN:
$qb->leftJoin('user_survey_status_entries',
'firstAccess',
Join::WITH,
$qb->expr()->in($qb2->getDQL())
);
In your case, don't forget to move the us.userSurveyID = firstAccess.userSurveyID condition into $qb2.