OK, so I'm rewriting some code, using Doctrine ORM (2.5).
The old code creates a query that has something like this:
SELECT * FROM couples INNER JOIN individuals ON (couples.id = individuals.couple_id)
GROUP BY couples.id
HAVING SUM(individuals.date_of_birth <= '1976-01-01') > 0
I have no clue how to implement this best using the Doctrine QueryBuilder. This is a very simplified example, the real query is much longer and has a few HAVING clauses, all of which use SUM(some_condition) > 0
to ensure that only Couples that contain a matching Individual will be retrieved.
I can add having clauses in Doctrine using $queryBuilder->having()
, but I cannot do so using the SUM()
function. Any ideas?