How to hydrate an Entity to its object when ordering when a specific computed field?
I need to get the diff from some integer, I've a column 'number' with value like 1 and -1, then I want to use SUM()
to compute the difference.
My DQL is:
SELECT
SUM(av.number) AS number_diff,
a
FROM
Articles a
LEFT JOIN a.numbers av
GROUP BY
av.article
ORDER BY
number_diff DESC
It's working but I get a result like this :
array
0 =>
arra开发者_如何学运维y
0 =>
object (Article)
.... properties
'vote_diff' => string '850' (length=3)
I need to get rid of such structure and get it in this format:
array
0 =>
object (Article)
.... properties
How can I do this?
This is not possible, as number_diff
is a computed column. It's not part of the entity.
So, each row is an array containing both the entity and the computed column, instead of just the entity.
精彩评论