doctrine posts

Sorting with `FIELD()` function in Doctrine

I recently needed to sort query results to match the order of IDs passed to it for use in a WHERE … IN() clause. In MySQL, this can be done using the FIELD() function in the ORDERY BY clause. For Doctrine, which doesn’t have the FIELD() function and doesn’t allow functions in the ORDER BY clause, there’s a little more work needed to make use of it.

Continue reading post "Sorting with `FIELD()` function in Doctrine"