Skip to end of metadata
Go to start of metadata

<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_Adapter_Doctrine - Jason Eisenmenger Component Proposal

Proposed Component Name Zend_Paginator_Adapter_Doctrine - Jason Eisenmenger
Developer Notes - Jason Eisenmenger
Proposers Jason Eisenmenger
Zend Liaison Ralph Schindler
Revision 1.0 - 5 September 2008: Initial Draft. (wiki revision: 10)

Table of Contents

1. Overview

Zend_Paginator_Adapter_Doctrine is an alternative to DbTable and allows the use of Doctrine

You may download the latest working class here

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

  • This component will work as a drop-in replacement to DbTable.

4. Dependencies on Other Framework Components

  • Zend_Paginator
  • Zend_Paginator_Exception
  • Zend_Paginator_Adapter_Interface

5. Theory of Operation

Exactly the same as DbTable

6. Milestones / Tasks

  • Milestone 1: [DONE] Write proposal
  • Milestone 2: [DONE] Post working prototype
  • Milestone 3: [DONE] Review by community
  • Milestone 4: Working prototype checked into the incubator supporting use cases #1, #2, ...
  • Milestone 5: Working prototype checked into the incubator supporting use cases #3 and #4.
  • Milestone 6: Unit tests exist, work, and are checked into SVN.
  • Milestone 7: Initial documentation exists.

7. Class Index

  • Zend_Paginator_Adapter_Doctrine

8. Use Cases

UC-01: Standard Usage
UC-01: Supplying a count query

9. Class Skeletons



Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Sep 18, 2008

    <p>A lot of people seem to like Doctrine, so I'm in favor of adding an adapter for it =) </p>

  2. Sep 19, 2008

    <p>Maybe you can implement one for Propel too?</p>

    <p><a href="">I've written one for Propel</a> which uses the symfony DbFinder plugin to mimic Doctrine's query format.<br />
    But it is probably better to implement without that plugin. <ac:emoticon ac:name="smile" /></p>

  3. Sep 21, 2008

    <p>Maybe it would also be a good idea to pass a Doctrine_Collection to the adapater, additional to Doctrine_Query. This would be a more generic approach.</p>

  4. Oct 13, 2008

    <p>Jason, your examples contain calls to setRouteName(), but those were only present in pre-release versions of Zend_Paginator. You should probably update your examples to reflect that.</p>

    <p>Otherwise, looks good. <ac:emoticon ac:name="smile" /></p>

  5. Nov 01, 2008

    <ac:macro ac:name="note"><ac:parameter ac:name="title">Zend Official Response</ac:parameter><ac:rich-text-body>

    <p>This proposal is accepted to the <strong>Zend Extras Incubator</strong> for development.</p>

    <p>We would like to see the following concerns met:</p>
    <li>This proposal and the proposal for <a href="">Zend_Auth_Adapter_Doctrine_Table</a> are combined into the ZendX_Doctrine namespace.</li>
    <li>Name changed to ZendX_Doctrine_Paginator_Adapter or something similar</li>
    <li>With this ZendX_Doctrine namespace, we would like to explore the possibility of allowing the top level class (presumably ZendX_Doctrine) to set up (bootstrap) this component for usage with doctrine- as well as checks to ensure that doctrine is available for use.</li>


  6. Dec 08, 2008

    <p>Zend_Paginator_Adapter_Propel is now 'ready for review'. </p>

  7. Mar 18, 2009

    <p>Jason, what is the status of this proposal? Do you plan to get this in to the 1.8 release?</p>

  8. Mar 18, 2009

    <p>That would be awesome!</p>

  9. Jul 07, 2009

    <p>I almost forgot about this thing. I was recently asked about it on IRC, so I will finish it now if possible. Not sure though want needs to be done except the tests... (any dependencies?) </p>

    <p>... Was actually referring to this proposal: <a class="external-link" href=""></a></p>

  10. Aug 12, 2009

    <p>I would strongly suggest ZendX_Doctrine_Paginator or ZendX_Doctrine_PaginatorAdapter for the name. (Same goes for Propel.)</p>

    <p>I have found a bug, by the way. Really, it's a bug in Doctrine, but you can fix it in this adapter. Namely that Doctrine doesn't check for null values before trying to set them in places where they will cause problems.</p>

    <ac:macro ac:name="code"><ac:default-parameter>php</ac:default-parameter><ac:plain-text-body><![CDATA[

    • Returns a collection of items for a page.
    • @param integer $offset Page offset
    • @param integer $itemCountPerPage Number of items per page
    • @return Doctrine_Collection
      public function getItems($offset, $itemCountPerPage)
      if ($offset !== null)
      Unknown macro: { $this->_query->offset($offset); }

      if ($itemCountPerPage !== null)

      Unknown macro: { $this->_query->limit($itemCountPerPage); }

      return $this->_query->execute();

      <p>If we want to return an array, we should do this instead:</p>

      <ac:macro ac:name="code"><ac:default-parameter>php</ac:default-parameter><ac:plain-text-body><![CDATA[

      • Returns an array of items for a page.
      • @param integer $offset Page offset
      • @param integer $itemCountPerPage Number of items per page
      • @return array
        public function getItems($offset, $itemCountPerPage)
        if ($offset !== null)

    if ($itemCountPerPage !== null)

    Unknown macro: { $this->_query->limit($itemCountPerPage); }

    return $this->_query->execute(array(), Doctrine::HYDRATE_ARRAY);

    <p>Either way, the collection should handle like an array.</p>

  11. Aug 13, 2009

    <p>One more comment.</p>

    <p>Hydration should be optional to the user with a method like setHydrationMode(). I would recommend setting up the controller like this:</p>

    <ac:macro ac:name="code"><ac:default-parameter>php</ac:default-parameter><ac:plain-text-body><![CDATA[

    • Constructor.
    • @param Doctrine_Query $query The select query
    • @param integer $hydrationMode Hydration mode
      public function __construct(Doctrine_Query $query, $hydrationMode = null)
      $this->_query = $query;

    if ($hydrationMode !== null)

    Unknown macro: { $this->setHydrationMode($hydrationMode); }


  12. Dec 13, 2009

    <p>Just wanted to say that this component works fantastic <ac:emoticon ac:name="smile" /><br />
    And that I also love the idea to pass the Doctrine_Collection to the adapater, additional to Doctrine_Query</p>

    1. Dec 14, 2009

      <p>Doctrine_Collection implements Countable and IteratorAggregate, so it should be useable directly with the Zend_Paginator_Iterator or since you in fact don't need Doctrine_Collections's Features, you can extract the array out of the collection (Doctrine_Collection->getData()) and use the Zend_Paginator_Array.</p>

  13. Mar 16, 2010

    <p>Is there a working version somewhere?</p>

    1. Mar 17, 2010

      <p>It's in the proposal.</p>

      <p><a class="external-link" href=""></a></p>