How can I use efficiently paginate with doctrine in Symfony 2?

我怕爱的太早我们不能终老 提交于 2019-12-07 06:50:26

问题


I would like to use Doctrine ORM and a pagination method in Symfony. KnpPaginatorBundle looks simple and easy to use. I also use Doctrine repositories because the queries can be easily reused and tested.

This bundle works like others I found. It needs the query builder as parameter. Is there a better way to do this than giving each repository function the paginator as a parameter (or null)? I do not want to paginate every query result so I do not think that the described solution is the best and I am looking for sugestions.


回答1:


I know two bundles for doing that:

  • https://github.com/KnpLabs/KnpPaginatorBundle
  • https://github.com/whiteoctober/WhiteOctoberPagerfantaBundle

Both can paginate ORM/Query or ORM/QueryBuilder (and more).



来源:https://stackoverflow.com/questions/13714559/how-can-i-use-efficiently-paginate-with-doctrine-in-symfony-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!