I have a field in an entity in string type, I need order result in my dql to value integer
I have a field in an entity in string type, I need the result sorted by that field but converted in an integer.
Some like this (MySQL Query):
SELECT * FROM table1 ORDER BY CONVERT(code, UNSIGNED);
How do I create this query in doctrine?
UPDATE
I managed to do it with the cast function thanks to this post:
CASTING attributes for Ordering on a Doctrine2 DQL Query
I have created my own function to implement this feature.
Official doc in doctrine: