如何在Symfony 2中有效地使用分歧与教义? [英] How can I use efficiently paginate with doctrine in Symfony 2?

查看:131
本文介绍了如何在Symfony 2中有效地使用分歧与教义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Symfony中使用Doctrine ORM和分页方法。 KnpPaginatorBundle看起来简单易用。我也使用Doctrine存储库,因为这些查询可以轻松重用和测试。



这个包与我发现的其他类似。它需要查询构建器作为参数。有没有更好的方式来做到这一点,而不是将每个存储库函数作为一个参数(或null)的分页符?我不想分页每个查询结果,所以我不认为所描述的解决方案是最好的,我正在寻找sugestions。

解决方案

我知道两个软件包:





两者都可以分页ORM / Query或ORM / QueryBuilder(等等)。


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.

解决方案

I know two bundles for doing that:

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

这篇关于如何在Symfony 2中有效地使用分歧与教义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆