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

Stephan Petzl spetzl at gmx.at
Wed Feb 23 08:41:43 CET 2011


Am 21.02.11 19:36, schrieb Franz Koch:
> Hey Stephan,
>
>> Unfortunatelly each game has ONE score (score is no domain object).
>> Therefore it seams unnatural to have a getMaxScore method inside the
>> game class.
>
> where is the problem when each game only has one score? What do you need
> MAX for?
>
> SELECT * FROM tx_ajadodpm_domain_model_game WHERE g.user2 = 0 ... ORDER
> BY tx_ajadodpm_domain_model_game.store DESC
>
> This could easily be done using QOM:
>
> Tx_Ext_Repository_GameRepository {
>
> public function findHighscoreGames() {
> $query = $this->createQuery();
> return $query->matching(
> $query->equals('user2', 0)
> )->setOrderings( array('score' =>
> Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING ) )
> ->setLimit(100)
> ->execute();
> }
>
> }
>
>
> Or did I get anything wrong here?
>

I want a list of games with the highest scores, but each user can have 
only one entry in this list. So I need the highest score of each user, 
sorted DESC. Your query, as I see it, just selects games, without 
calculating the maximum score for each user.

-- 
Best Regards
Stephan Petzl
http://www.ajado.com


More information about the TYPO3-project-typo3v4mvc mailing list