I have a DQL query containing a SELECT expression that’s only used for ordering:
SELECT u, (u.orderTotal / u.orderCount) AS orderAverage
FROM User u
ORDER BY orderAverage
I have to use this trick because so far, Doctrine does not support ordering by an expression.
That works fine, expect that for a reason outside the scope of this question, I’d like to have only u returned by getResult():
[0] => object(User)
[1] => object(User)
and not a nested array containing u and orderAverage:
[0] =>
[0] => object(User)
['orderAverage'] => float
[1] =>
[0] => object(User)
['orderAverage'] => float
I thought I’d read somewhere that there was a DQL keyword for not returning an expression in the result, but I’ve failed to find it in the documentation. It’d be something like:
SELECT u, IGNORE (u.orderTotal / u.orderCount) AS orderAverage
FROM ...
Does that exist, or did I dream?
Ok, I finally managed to find it in the EBNF documentation.
The correct keyword is
HIDDEN, and goes afterAS: