2

I'm aware of Doctrine's Paginator, but it works on DQL level. What I'm looking for is a way to implement pagination on repository level.

  • The first way I see is to incapsulate pagination within the repo:

    • by making all of it's methods accept two additional arguments, $offset and $limit, or

    • by implementing setOffset and setLimit methods within my repo that would affect all of it's find... methods (which is not good due to the DefaultRepositoryFactory implementation, which behaves as a Singleton Factory).

  • The other way is to make a ResultBuilder class as in this question. I don't really like this approach because it works on a prefetched result set, which makes extra data retrieval even with Doctrine's lazy-loading.

Which other approaches to the subject exist, and which approach would be the best for a Doctrine2 ORM user?

4

1 回答 1

0

我发现的一种可能的解决方案是制作相应的过滤器(使用 LIMIT 语句),如官方文档中所述,并在使用它的查询方法(包括自定义)之前将该过滤器应用于存储库。

于 2014-02-08T11:21:21.173 回答