<p>Maybe you can implement one for Propel too?</p>
<p><a href="http://www.strictlyphp.com/blog/2008/09/19/zend_pagination-adapter-for-propel/">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>
<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>
<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>
<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>
<ul>
<li>This proposal and the proposal for <a href="http://framework.zend.com/wiki/display/ZFPROP/Zend_Auth_Adapter_Doctrine_Table">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>
</ul>
<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>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>
<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>
<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>
15 Comments
comments.show.hideSep 18, 2008
Jurrien Stutterheim
<p>A lot of people seem to like Doctrine, so I'm in favor of adding an adapter for it =) </p>
Sep 19, 2008
Sam Hauglustaine
<p>Maybe you can implement one for Propel too?</p>
<p><a href="http://www.strictlyphp.com/blog/2008/09/19/zend_pagination-adapter-for-propel/">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>
Sep 21, 2008
D. Werner
<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>
Oct 13, 2008
Matthew Ratzloff
<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>
Nov 01, 2008
Ralph Schindler
<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>
<ul>
<li>This proposal and the proposal for <a href="http://framework.zend.com/wiki/display/ZFPROP/Zend_Auth_Adapter_Doctrine_Table">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>
</ul>
</ac:rich-text-body></ac:macro>
Dec 08, 2008
Derek Martin
<p>Zend_Paginator_Adapter_Propel is now 'ready for review'. </p>
Mar 18, 2009
Wil Sinclair
<p>Jason, what is the status of this proposal? Do you plan to get this in to the 1.8 release?</p>
Mar 18, 2009
Jens Kleikamp
<p>That would be awesome!</p>
Jul 07, 2009
D. Werner
<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="http://framework.zend.com/wiki/pages/viewpage.action?pageId=3866950">http://framework.zend.com/wiki/pages/viewpage.action?pageId=3866950</a></p>
Aug 12, 2009
Matthew Ratzloff
<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[
/**
*
*/
public function getItems($offset, $itemCountPerPage)
{
if ($offset !== null)
if ($itemCountPerPage !== null)
return $this->_query->execute();
}
]]></ac:plain-text-body></ac:macro>
<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[
/**
*
*/
public function getItems($offset, $itemCountPerPage)
{
if ($offset !== null)
if ($itemCountPerPage !== null)
return $this->_query->execute(array(), Doctrine::HYDRATE_ARRAY);
}
]]></ac:plain-text-body></ac:macro>
<p>Either way, the collection should handle like an array.</p>
Aug 13, 2009
Matthew Ratzloff
<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[
/**
*
*/
public function __construct(Doctrine_Query $query, $hydrationMode = null)
{
$this->_query = $query;
if ($hydrationMode !== null)
}
]]></ac:plain-text-body></ac:macro>
Dec 13, 2009
Aleksandar Scepanovic
<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>
Dec 14, 2009
Benjamin Steininger
<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>
Mar 16, 2010
Goran Juric
<p>Is there a working version somewhere?</p>
Mar 17, 2010
Matthew Ratzloff
<p>It's in the proposal.</p>
<p><a class="external-link" href="http://framework.zend.com/wiki/download/attachments/7831683/Doctrine.php">http://framework.zend.com/wiki/download/attachments/7831683/Doctrine.php</a></p>