I'm not sure if it's useful, but you can get around it by doing a quick test: if ($page > $paginator->count()) return null;
-- Hector On Mon, May 17, 2010 at 10:54 AM, Bartosz Maciaszek < [email protected]> wrote: > Hi all, > > I just had a bit of work to do with Zend_Paginator (nb. with > Zend_Db_Table_Select) and I noticed some weird behaviour. Let's take > this simple code as an example: > > $paginator = Zend_Paginator::factory($table->select()->where('foo is > null')); > $paginator->setCurrentPageNumber(1); > > If the query returns more than default number of rows in Paginator > (10) then I get Iterator with 10 first elements and that's quite all > right. > > Now, imagine that query returns 100 rows (which makes 10 pages in > default configuration). User requests page number 20: > > $paginator->setCurrentPageNumber(20); > > As a result I get 10 *last* rows (exactly the same when requesting > 10th page). My expectation is to get empty Iterator, because page > number 20 does not exists. > > I dig into the code and I found, that's because of > normalizePageNumber() method which changes my requested 20 into 10. > > Is that behaviour really helpful? I think it should be parametrized > because sometimes (i.e. in my case - fetching next pages while > scrolling the page down) it completely distorts the effect - at the > end I get last page every time I request the next one. > > What do you think? > > Regards, > Bartosz > > -- > Never regret. If it's good - it's wonderful. If it's bad - it's experience. >
