Zend_Paginator and Zend_Db_Table_Select objects
Hello,
I just noticed the new components on the online manual and decided to
try out the new paginator. Very nice!
I found a couple small bugs that you might want to have a look at:
1) An exception is thrown when using a Zend_Db_Table_Select object: "No
table has been specified for the FROM clause". To get around this, I
had to call from() on the select object (which is redundant for
Zend_Db_Table_Select).
<?php
$table = new MyTable();
$select = $table->select()
->from($table) // required for paginator?
;
$paginator = Zend_Paginator::factory($select);
?>
2) The paginator will break if you set the current page number before
setting the item count per page. It seems that setting the page number
executes the query to retrieve the items. Is this intentional?
<?php
$page = 1;
$itemsPerPage = 5;
// Not working
$paginator = Zend_Paginator::factory($select);
$paginator->setCurrentPageNumber($page);
$paginator->setItemCountPerPage($itemsPerPage);
$items =
$paginator->getItems(); // Incorrectly returns 10 items (the
default count per page)
// This works
$paginator = Zend_Paginator::factory($select);
$paginator->setItemCountPerPage($itemsPerPage);
$paginator->setCurrentPageNumber($page); // Must be done last
$items =
$paginator->getItems(); // Correctly returns 5 items
?>
Otherwise, the paginator
is working nicely and I plan to replace my current poor-boy's paginator
with the Zend one very soon :)
-Hector