CASTING attributes for Ordering on a Doctrine2 DQL Query
I am trying to get Doctrine2 Entities , ordered by their ID which apparently is a String even though it contains only Numbers. So what I would like to do is something like this: SELECT entity1, cast (entity1.id AS integer) AS orderId FROM Namespace\Bla\MyEntity ORDER BY orderId Is there a way to do something like this in Doctrine2 ? Or, what would be the best practise to get my Result if i can't change the type of the id ( due to customer requirements of course )? Attention : I am not asking SQL Code, i am asking for a Doctrine2 Solution, preferably in DQL You should be able to add your own