[Flow] custom query with limit

Pascal Geldmacher pascal.geldmacher at orangefluid.com
Mon Feb 22 11:06:46 CET 2016


Hi,

i've the following problem. I use the \TYPO3\Flow\Persistence\Doctrine\Repository for one of my repositories because i have a completely individual query. In that query i use groupBy, orderBy and also limit. The problem is to set the limit. My DQL completely ignore the limit values. But i don't know why. 

Here an example of my Query:

	$builder = $this->entityManager->createQueryBuilder('\Orangefluid\Orangelab\Domain\Model\TimeTracking');
		$builder->select(array('tt','sum(tt.period) as period, max(tt.date) as maxDate'))
			->from('\Orangefluid\Orangelab\Domain\Model\TimeTracking', 'tt');

        if(!empty($from) && !empty($to)) {
            $builder->where('tt.date >= '.$from)->andWhere('tt.date <= '.$to);
        }

		if(!empty($user)){
			$builder->andWhere('tt.user = ' .$user->getUid());
		}
		$group = intval($group);
		if($group === 1) {
			$builder->groupBy('tt.project');
		}else {
			$builder->groupBy('tt.uid');
		}

        $builder->orderBy('maxDate', 'DESC');
		$builder->setFirstResult(0);
		$builder->setMaxResults(10);

		$query = $builder->getDQL();

		$tmpReports = $this->entityManager->createQuery($query)->execute();

Can anyone help me? Or can i do that query with the flow basics too?

Thanks



More information about the Flow mailing list