What you are looking for are the calculated values ββin the ORDER and HIDDEN clauses.
In general, you need to do something like the following:
SELECT a, b, (SOME_COMPUTATION()) AS computed FROM ... ORDER BY computed ASC
To βhideβ the computed value from the result set, starting with Doctrine ORM 2.3, you can use the HIDDEN clause:
SELECT a, b, (SOME_COMPUTATION()) AS HIDDEN computed FROM ... ORDER BY computed ASC
Here's what your DQL looks like:
SELECT p, (p.views * 0.1) + (p.likes * 0.9) AS HIDDEN ratingPhoto FROM AppBundle:Photo p ORDER BY ratingPhoto DESC
source share