[TYPO3-mvc] domain objects and mysql-aggregation attributes

Franz Koch typo3.RemoveForMessage at elements-net.de
Mon Feb 21 14:12:59 CET 2011


Hey,

> I'm not sure how to handle this:
>
> I have a game model which has a score property.
> Now I want to show the highscore of the day, and therefor i want to use
> mysql's MAX function:
>
> SELECT g.*, MAX(g.score) as maxScore
> FROM tx_ajadodpm_domain_model_game g
>
> But when I try to access {game.maxScore} in the view, I don't get
> anything back. I have also tried to make "maxScore" a property of the
> model "game", but AFAIK this is not right in therms of DDD. Apart from
> this, it doesn't work anyway, still getting nothing back :)

extbase is only mapping persistable properties to your objects. So if 
maxScore is not persistable (has a property and also a TCA setting) it 
can't get mapped.

> How would you handle this?

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).

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list