I have two objects
This article relates to a user named 'popularByUsers'
Now I would like to get the order of articles by the number of liked, but:
- I do not want to have the 'numberOfLikes' property because it is too big a problem to update it.
- I have too many articles (100k +) to be realistic for "sorting" in the PHP side (and the fact that we reach the limit of sorting is the reason why I ask this question)
- I can live without getting the amount I liked in the return values (since the serializer will later moisten it)
what i have now:
$builder = $this->createQueryBuilder('a');
->select('COUNT(u) AS nbrLikes')
->leftJoin('a.likedByUsers', 'u')
->orderBy('nbrLikes', 'DESC')
->groupBy('a.id')
->getQuery()
->getResult()
;
( 0 ),
->select('a, COUNT(u) AS HIDDEN nbrLikes')
, a GROUP BY
?