I would like to design a query in my repository, but it's a bit complex to do it with the queryBuilder method, so I prefer a complete query.
$queryBuilder = $this->_em->createQueryBuilder(
"SELECT need_id
FROM notification_need
WHERE user_id <> :user
AND check_date >=
(SELECT check_date
FROM notification_need
WHERE user_id = :user
ORDER BY check_date DESC
LIMIT 1)
AND need_id IN
(SELECT id
FROM option_need
WHERE commande_id IS NULL)
")
->setParameter('user', $userId);
return $queryBuilder->getQuery()->getResult();
But an error is generated when executing this request:
[Syntax Error] line 0, col -1: Error: Expected IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | "(" Subselect ")" | CaseExpression, got end of string.