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:

  1. Lazy load

  2. use the Paginator (as stated by @Marco here)

  3. Use Doctrine\Common\Collections\Collection::slice()

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)