Reputation: 1468
I'm using "NativeQuery" with Doctrine and my query has an INNER JOIN. I want to do "Limit" with only the first table for the results. But, In Mysql, "Limit" takes into account joined tables. Any idea on how to achieve this? Thanks
Upvotes: 0
Views: 116
Reputation: 29
here is an example with QueryBuilder you can adapt it to you own usage
$qb = $this->createQueryBuilder('a');
$qb
->join('a.advert', 'adv')
->addSelect('adv')
;
$qb->setMaxResults($limit);
return $qb
->getQuery()
->getResult()
;
you've said you are french here is a good tutorial
Récupérer ses entités avec Doctrine2
Upvotes: 0
Reputation: 2106
I think that you are looking for Doctrine Pagination. http://doctrine-orm.readthedocs.org/projects/doctrine-orm/en/latest/tutorials/pagination.html
Upvotes: 1