|
|
@@ -166,7 +166,7 @@ $paginator->setCurrentPageNumber($this->_getParam('page'));
|
|
|
$this->view->paginator = $paginator;
|
|
|
]]></programlisting>
|
|
|
</sect2>
|
|
|
-
|
|
|
+
|
|
|
<sect2 id="zend.paginator.usage.dbselect">
|
|
|
<title>The DbSelect and DbTableSelect adapter</title>
|
|
|
<para>
|
|
|
@@ -179,16 +179,16 @@ $this->view->paginator = $paginator;
|
|
|
times faster than fetching an entire result set and using
|
|
|
<methodname>count()</methodname>. Especially with large collections of data.
|
|
|
</para>
|
|
|
-
|
|
|
+
|
|
|
<para>
|
|
|
The database adapters will try and build the most efficient query that will execute
|
|
|
on pretty much all modern databases. However, depending on your database or even your
|
|
|
own schema setup, there might be more efficient ways to get a rowcount. For this
|
|
|
scenario the database adapters allow you to set a custom COUNT query. For example,
|
|
|
if you keep track of the count of blog posts in a separate table, you could achieve a
|
|
|
- faster count query with the following setup:
|
|
|
+ faster count query with the following setup:
|
|
|
</para>
|
|
|
-
|
|
|
+
|
|
|
<programlisting language="php"><![CDATA[
|
|
|
$adapter = new Zend_Paginator_Adapter_DbSelect($db->select()->from('posts'));
|
|
|
$adapter->setRowCount(
|
|
|
@@ -203,11 +203,11 @@ $adapter->setRowCount(
|
|
|
|
|
|
$paginator = new Zend_Paginator($adapter);
|
|
|
]]></programlisting>
|
|
|
-
|
|
|
+
|
|
|
<para>
|
|
|
This approach will probably not give you a huge performance gain on
|
|
|
small collections and/or simple select queries. However, with complex
|
|
|
- queries and large collections, a similar approach could give you a
|
|
|
+ queries and large collections, a similar approach could give you a
|
|
|
significant performance boost.
|
|
|
</para>
|
|
|
</sect2>
|