doctrine querybuilder limit and offset
This is a know issue where setFirstResult()
and setMaxResults()
need to be use with care if your query contains a fetch-joined collection.
As stated about First and Max Result Items:
If your query contains a fetch-joined collection specifying the result limit methods are not working as you would expect. Set Max Results restricts the number of database result rows, however in the case of fetch-joined collections one root entity might appear in many rows, effectively hydrating less than the specified number of results.
Instead, you can:
Lazy load
use the Paginator (as stated by @Marco here)