CASTING attributes for Ordering on a Doctrine2 DQL Query

后端 未结 7 470
一向
一向 2020-12-03 03:33

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

7条回答
  •  一向
    一向 (楼主)
    2020-12-03 03:57

    Not sure if this works, but to access an entity ID you need the IDENTITY() DQL function. Try this:

    SELECT entity1  FROM Namespace\Bla\MyEntity  ORDER BY IDENTITY(entity1)
    

提交回复
热议问题