I have an object with an ArrayCollection field. In annotations I can write
@ORM\OrderBy({"somefield" = "DESC"})
and the collection that I get from this object will be automatically ordered.
My question is, can I sort by aggregate fields?
My current problem: I have 2 fields in the collection: visited
and shown
, I would like to sort the collection by rating index, which is: visited / shown
. I tried to write it in the annotation, but it says that this must be a valid field. I know how to do this with DQL, but I don't know how to recreate it in an Entity declaration with annotations.
Thanks in advance!
source share