Skip to end of metadata
Go to start of metadata

<ac:macro ac:name="note"><ac:parameter ac:name="title">Under Construction</ac:parameter><ac:rich-text-body>
<p>This proposal is being merged with <a class="external-link" href=""></a>ën+Stutterheim+and+Matthew+Ratzloff</p></ac:rich-text-body></ac:macro>

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

Zend Framework: Zend_Paginator - Matthew Ratzloff Component Proposal

Proposed Component Name Zend_Paginator - Matthew Ratzloff
Developer Notes - Matthew Ratzloff
Proposers Matthew Ratzloff
Darby Felton, Zend liaison
Revision 0.1 - First version (wiki revision: 8)

Table of Contents

1. Overview

Zend_Paginator is a pagination class for both database- and view-level pagination. Users supply a page number and an optional configuration object and the rest is handled more or less seamlessly. The database strategy is the default, but view-level pagination can be selected in the options. For database pagination, users should have their models implement Zend_Paginator_Pageable_Interface.

Disclaimer: This is something I threw together over a couple of hours on Christmas Eve. I haven't coded anything yet, so I'm not sure if everything would work exactly as currently described. I really should probably finish all my other proposals and not-yet-proposals before I create another proposal, but this is something that a lot of people probably need right away.

2. References

I really wasn't impressed with any other pagination implementations I came across. In general, they were just too limiting.

3. Component Requirements, Constraints, and Acceptance Criteria

  • This component will paginate database and arbitrary result sets.
  • This component will be flexible enough to allow users to implement any page-to-page navigation they like.
  • This component will not be a one-size-fits-all solution. That means that there may be a little more work involved on the part of the user when initially incorporating this class into their project.

4. Dependencies on Other Framework Components

  • Zend_Exception
  • Zend_Db
  • Probably not Zend_View (but we'll see)

5. Theory of Operation

6. Milestones / Tasks

  • Milestone 1: Proposal is finished.
  • Milestone 2: Working prototype checked into the incubator supporting use cases #1, #2, ...
  • Milestone 3: Working prototype checked into the incubator supporting use cases #3 and #4.
  • Milestone 4: Unit tests exist, work, and are checked into SVN.
  • Milestone 5: Initial documentation exists.

7. Class Index

  • Zend_Paginator
  • Zend_Paginator_Exception
  • Zend_Paginator_Page
  • Zend_Paginator_Pageable_Interface
  • Zend_Paginator_Strategy_Db
  • Zend_Paginator_Strategy_View

8. Use Cases


Database-level pagination example


Model (which implements Zend_Paginator_Pageable_Interface):

View (page_selector.php partial):


View-level pagination example


View (page_selector.php partial):

9. Class Skeletons

Here's a partial list. This includes the public methods.



pagination pagination Delete
paginator paginator Delete
paging paging Delete
pager pager Delete
zend_paginator zend_paginator Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Dec 24, 2007

    <p>Two comments to get any design discussion rolling:</p>

    <p>1. I'd like the DB strategy to return a statement and the view strategy to return some sort of array-like object (like a Rowset). I'd like them to have the same name, but that might be unfeasible... so I may have to end up stretching the concept of the Strategy pattern and just pass through variously-named strategy methods with __call().</p>

    <p>2. I don't like the fact that the Paginator object is implicitly modified by the view (and I especially don't like the fact that a change takes place to the object when calling a get*() method--see above for a possible solution).</p>

  2. Mar 17, 2008

    <p>For the Zym project ( I wrote a pagination component myself.<br />
    It exists of an abstract class and three concrete classes (for arrays, Iterator instances and Db_Table instances).<br />
    I didn't use a separate Page class for Zym_Paginate, because I didn't see any added value over an array/(Limit)Iterator or Row_Set. Please have a look at Zym_Paginate and let me know what you think.</p>

    <p>As for the idea of a pagination component in general: it's got my vote <ac:emoticon ac:name="smile" /></p>