whiteoctober / Pagerfanta

Pagination for PHP.
Other
1.59k stars 2 forks source link

Count with Group by fails #251

Closed Netzhirsch closed 6 years ago

Netzhirsch commented 6 years ago

I have the following query:

$qb = $em->createQueryBuilder(); $qb->select('de', 'COUNT(de.auftragsnummer) as menge'); $qb->from('App\Entity\DispositionsplanEintrag', 'de'); $qb->where('de.geloescht IS NULL'); $qb->groupBy('de.auftragsnummer'); $qb->orderBy('de.auftragsnummer', 'ASC');

Executed by the following code:

$query = $qb->getQuery(); $paginator = $this->get('knp_paginator'); $eintraege = $paginator->paginate($query, $request->query->getInt('page', 1), 20);

it results in having the variable "menge" always has the value 1. if I execute: $eintraege = $query->getResult();

then the value of "menge" is correct. Is there anything wrong in my example, or is it a bug?

Thank you!

stof commented 6 years ago

you are using knp_paginator in this code, not pagerfanta.

Netzhirsch commented 6 years ago

omg, sorry :D