I have 3 entities in Symfony. Candidate
, School
, Game
a candidate is assigned to one school and can start games. The games entity contains the score (of that) game. So far so good, here comes the tricky part:
I have to display to the candidates, what rank they have currently, as well as the top 10 players.
I know, I could use a native query for mysql and do something like proposed here: https://stackoverflow.com/a/3333697/2989952
But then, to get the rank of the candidate I'd have to load all entries from the db and loop throu them in PHP (or with Doctrines Criteria
). Is there a better way to get the rank? I could also add a column point's or something in the candidate entity and update that after every game and then just sort by that column, still I'd have to loop throu all entries again in PHP.
Thanks for your help.