你如何处理Zend_Paginator?

时间:2021-12-29 11:09:43

I was looking at Zend_Paginator in Zend Framework project using MVC, and it looks like an intersting tool.

我正在使用MVC查看Zend Framework项目中的Zend_Paginator,它看起来像一个有趣的工具。

It looks like we can give a select object as argument to the factory, it's interesting because it means that i should return a select object from my model, is it a good way to do ?

看起来我们可以将select对象作为工厂的参数给出,这很有意思,因为这意味着我应该从模型中返回一个select对象,这是一个好方法吗?

It seems to be a bit heavy to do this, since it won't be needed all the times...

这样做似乎有点沉重,因为它不会一直需要......

I can also give an array, which could come as a result of my method model, but in the case where i have a lot of data, it could be complicated to retrieve all the data from my database each times.

我也可以给出一个数组,这可能是我的方法模型的结果,但是在我有大量数据的情况下,每次从数据库中检索所有数据可能很复杂。

How can i handle this ?

我怎么处理这个?

3 个解决方案

#1


From the doc: http://framework.zend.com/manual/en/zend.paginator.usage.html

来自doc:http://framework.zend.com/manual/en/zend.paginator.usage.html

However, it is possible to directly supply a count or count query yourself. See the setRowCount() method in the DbSelect adapter for more information.

但是,可以自己直接提供计数或计数查询。有关详细信息,请参阅DbSelect适配器中的setRowCount()方法。

And

In the case of the Null adapter, in lieu of a data collection you must supply an item count to its constructor.

对于Null适配器,您必须为其构造函数提供项目计数,而不是数据集合。

I would suggest doing the count yourself, and then manually setting it. That is, based upon the reading I just did. Also, the doc states that if you go the NULL route, you can provide an item-count (Integer) to the Paginator constructor instead - this seems a bit more reasonable than querying for the number with each request.

我建议自己做计数,然后手动设置它。也就是说,基于我刚才的阅读。此外,doc指出,如果你使用NULL路由,你可以向Paginator构造函数提供item-count(Integer) - 这似乎比查询每个请求的数字更合理。

#2


I have posted about this a few weeks ago. It is found here: http://blog.ekini.net/2009/06/22/zend-framework-how-to-use-zend_paginator/

几个星期前我发布了这个帖子。它可以在这里找到:http://blog.ekini.net/2009/06/22/zend-framework-how-to-use-zend_paginator/

It is a pretty straight-forward tutorial. It starts with the form, then the controller, and goes down to the view and the paginator file.

这是一个非常简单的教程。它从表单开始,然后是控制器,然后转到视图和paginator文件。

#3


Well, i finally found an interesting way to do.

好吧,我终于找到了一个有趣的方法。

First, i implemented a Domain Model pattern after a read on Matthew Weier O'Phinney's blog, who explains how to.

首先,我在阅读Matthew Weier O'Phinney的博客后实现了一个领域模型模式,该博客解释了如何。

Then, i created my own adapter of Zend_Paginator, to agree with my Model.

然后,我创建了自己的Zend_Paginator适配器,同意我的模型。

It's the most interesting way to do, i've found until now.

这是最有趣的方式,我发现到现在为止。

#1


From the doc: http://framework.zend.com/manual/en/zend.paginator.usage.html

来自doc:http://framework.zend.com/manual/en/zend.paginator.usage.html

However, it is possible to directly supply a count or count query yourself. See the setRowCount() method in the DbSelect adapter for more information.

但是,可以自己直接提供计数或计数查询。有关详细信息,请参阅DbSelect适配器中的setRowCount()方法。

And

In the case of the Null adapter, in lieu of a data collection you must supply an item count to its constructor.

对于Null适配器,您必须为其构造函数提供项目计数,而不是数据集合。

I would suggest doing the count yourself, and then manually setting it. That is, based upon the reading I just did. Also, the doc states that if you go the NULL route, you can provide an item-count (Integer) to the Paginator constructor instead - this seems a bit more reasonable than querying for the number with each request.

我建议自己做计数,然后手动设置它。也就是说,基于我刚才的阅读。此外,doc指出,如果你使用NULL路由,你可以向Paginator构造函数提供item-count(Integer) - 这似乎比查询每个请求的数字更合理。

#2


I have posted about this a few weeks ago. It is found here: http://blog.ekini.net/2009/06/22/zend-framework-how-to-use-zend_paginator/

几个星期前我发布了这个帖子。它可以在这里找到:http://blog.ekini.net/2009/06/22/zend-framework-how-to-use-zend_paginator/

It is a pretty straight-forward tutorial. It starts with the form, then the controller, and goes down to the view and the paginator file.

这是一个非常简单的教程。它从表单开始,然后是控制器,然后转到视图和paginator文件。

#3


Well, i finally found an interesting way to do.

好吧,我终于找到了一个有趣的方法。

First, i implemented a Domain Model pattern after a read on Matthew Weier O'Phinney's blog, who explains how to.

首先,我在阅读Matthew Weier O'Phinney的博客后实现了一个领域模型模式,该博客解释了如何。

Then, i created my own adapter of Zend_Paginator, to agree with my Model.

然后,我创建了自己的Zend_Paginator适配器,同意我的模型。

It's the most interesting way to do, i've found until now.

这是最有趣的方式,我发现到现在为止。