[TYPO3-mvc] domain objects and mysql-aggregation attributes
Stephan Petzl
spetzl at gmx.at
Mon Feb 21 18:15:04 CET 2011
Am 21.02.11 14:12, schrieb Franz Koch:
> you could add a getMaxScore property, iterate over all scores and return
> the highest one fetch the highest score for a game via a call to a
> scoreRepository inside your getter.
> Or use a viewHelper that's internally doing one of the mentioned things
> (or probably triggering a highScore service etc. which is doing one the
> mentioned things).
>
Unfortunatelly each game has ONE score (score is no domain object).
Therefore it seams unnatural to have a getMaxScore method inside the
game class.
I guess that maybe it would be better to not use ORM for things like
showing highscores, because it seams to me that a highscore is nothing
persistable or even writable, its just a calculated array of data.
I solved this issue by:
SELECT g.*,MAX(g.score) as score
FROM fe_users u
INNER JOIN tx_ajadodpm_domain_model_game g ON g.user1 = u.uid
WHERE g.crdate > 0 AND
g.deleted=0 AND
g.hidden=0 AND
u.deleted=0 AND
u.disable=0 AND
g.user2 = 0
GROUP BY g.user1
ORDER BY MAX(g.score) DESC
LIMIT 0, 100";
the first selection of "score" is overridden by the second one -> when I
access {game.score} in the view, I get my highscore
--
Best Regards
Stephan Petzl
http://www.ajado.com
More information about the TYPO3-project-typo3v4mvc
mailing list