I'm trying to convert the following native sql query to a querybuilder instance for doctrine2 but without any success.
SELECT r1.*
FROM reservations r1
INNER JOIN (
SELECT user, max(occurrence) AS max
FROM reservations
WHERE team = 'team-id'
AND canceled = 0
GROUP BY user
) r2
ON r1.occurrence = r2.max AND r1.user = r2.user
WHERE r1.team = 'team-id'
AND r1.canceled = 0
AND r1.occurrence >= '2018-10-08'
ORDER BY occurrence DESC;
I've tried creating a querybuilder while using the inner join but that's not possible because it doesn't allow subqueries on that point. Even tried a ->where($qb->expr()->in()) but didn't work... so i'm a little bit out of options right now.
What i would like to accomplish is to get the last made reservation for all users within a specific team.
Can someone (with these type of experiences with doctrine) please help me?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire