[TYPO3-mvc] Counting children in controller - performance

Martin Kokes shr3k at typo3-hosting.com
Wed Sep 24 18:23:53 CEST 2014


Hello list,

I have following simplified model Installation <n:1> Model <n:1> <Make> and 
I want to display models for make together with count of installations for 
each model (and sum of them). Is there a better performance way than this
---
public function thumbnailsAction(\***\***\Domain\Model\Make $make) {
    $models = $this->modelRepository->findByMake($make);
    $installationsCount = 0;
    foreach ($models as $model) {
        $count = $this->installationRepository->countByModel($model);
        $model->installationsCount = $count;
        $installationsCount += $count;
    }
    $this->view->assign('make', $make);
    $this->view->assign('installationsCount', $installationsCount);
    $this->view->assign('models', $models);
}
---
in my ModelController.php? I mean beside of custom SQL query? As SQLguy I'd 
like join and group them in one query. :-)

Martin 



More information about the TYPO3-project-typo3v4mvc mailing list