views:

173

answers:

3

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

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 ?

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 ?

+2  A: 

From the 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.

And

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

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.

Jonathan Sampson
A: 

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/

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.

wenbert
A: 

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.

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

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

Boris Guéry