ZF-3720: Setting the current page number causes the items to be fetched prematurely
Description
Zend_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 select query to retrieve the items.
<?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 ?>
Comments
Posted by Jurrien Stutterheim (norm2782) on 2008-07-23T09:43:15.000+0000
Fixed in revision 10307