Hello, Returning last page if requested page number is higher than total pages amount is some kind of time-defined standard. More than that, normally user should not enter page number manually.
2010/5/17 Bartosz Maciaszek <[email protected]>: > 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. > -- Sincerely yours, Aleksey V. Zapparov A.K.A. ixti FSF Member #7118 Mobile Phone: +34 617 179 344 Homepage: http://www.ixti.ru JID: [email protected] *Origin: Happy Hacking!
