Issue Bug Closed

#105418QueryBuilder: no longer possible to build advanced orderings with orderBy

Michael Stopp 10/23/24, 16:58 updated 11/08/24, 10:07

Description

I’m basically repeating myself from 6 years ago (#84814): with the current QueryBuilder it seems impossible to do orderings that go beyond simple field list, i.e. something like in these real-life examples:

ORDER BY FIELD(eventtype, 0, 4, 1, 2, 3), sorting

or

ORDER BY CAST(SUBSTRING_INDEX(c.IP, '.', -1) AS UNSIGNED)

Before moving to Doctrine DBAL version 4 it was possible to achieve this with something like:

$queryBuilder->add('orderBy', 'FIELD(eventtype, 0, 4, 1, 2, 3), sorting')

How can we do this now, after the add() method was dropped in DBAL v4?

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.