orm: Doctrine Pagination With Left Join (ArrayCollection) NOT working correctly
Hi there. I have the following query:
$qb->select(array('c', 'd'))
->from($this->_rps('Client'), 'c')
->where('c.account = :account');
if ($searchTerm) {
$qb->andWhere('c.title LIKE :term');
$qb->setParameter('term', '%' . $searchTerm . '%');
}
$qb->leftJoin('c.domains', 'd');
$qb->setFirstResult($offset)->setMaxResults($limit);
$qb->setParameter('account', $account);
$query = $qb->getQuery();
$paginator = new Paginator($query, false);
return $paginator;
This is not working correctly. Only if I remove left join everything works fine. I have also tried new Paginator($query, true)…
I there any effective way to work with that returning always a paginator object?
Thank you in advance
About this issue
- Original URL
- State: open
- Created 8 years ago
- Comments: 20 (6 by maintainers)
@amirduran try groupBy the entity you want to setMaxResults on
Bump, this issue still occurs. Will try to provide an isolated test in upcoming weeks, when I find a moment of spare time.
DOCTRINE, Why don’t you like LEFT JOIN? It’s now almost 2024 and this issue still not fixed??? Odd items in resultset set to NULL??? For a simple DQL query: $qb = $this->createQueryBuilder(‘c’) ->addSelect(‘a’) ->addSelect(‘partial ch.{id}’) ->innerJoin(‘c.author’, ‘a’) ->innerJoin(‘a.channel’, ‘ch’) ->where(‘c.video = :video’) ->orderBy(‘c.likeCount - c.dislikeCount + (c.loveCount * 2)’, ‘desc’) ->addOrderBy(‘c.createdAt’, ‘desc’) ->setParameter(‘video’, $video->getId(), ‘ulid’); if ($user) { $qb->leftJoin(CommentReaction::class, ‘cr’, ‘WITH’, ‘c = cr.comment AND cr.user = :user’) ->addSelect(‘cr’) ->setParameter(‘user’, $user->getId(), ‘ulid’); }
Fetching 10 items, if $user is not null it always fails with odd items set to null in resultset.
I upgraded
doctrine/doctrine-orm-module
from 1.0.0 to 1.1.0, which installeddoctrine/orm
v2.5.5
. However, my problem mentioned above still persists.Any news regarding this bug? I’m facing exactly the same problem.