Feature #84814
closedSupport literal orderBy clauses
0%
Description
With the QueryBuilder it's currently not possible 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)
There should be something equivalent to selectLiteral for orderBy.
Without this, it can be difficult to properly migrate extensions from $GLOBALS['TYPO3_DB'] to Doctrine DBAL syntax.
Updated by Georg Ringer over 6 years ago
- Status changed from New to Needs Feedback
I would go with ->add('orderBy', 'FIELD(eventtype, 0, 4, 1, 2, 3)', true)
. what do you think?
Updated by Michael Stopp over 6 years ago
Oh great, thanks! I must admit that I wasn't aware of this. When I checked the API reference, I was looking for something more specific and thus must have missed this rather generic method. I guess this issue can be closed then.
I would suggest however, that the API core documentation should mention such possibilities (eg. add, selectLiteral, addSelectLiteral). Neither the page on QueryBuilder nor the one "Migrating from TYPO3_DB" do really point this out.
Updated by Georg Ringer over 6 years ago
- Status changed from Needs Feedback to Resolved
I added a PR to the docs https://github.com/TYPO3-Documentation/TYPO3CMS-Reference-CoreApi/pull/257