PEAR::DB_Pager: a very strange USAGE!!!!

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!


this is the usage code suggested by the author of PEAR::DB_Pager.

  require_once 'DB/Pager.php';
  $db = DB::connect('mysql://root@:localhost/global');
  $from = 0;   // The row to start to fetch from (you might want to get
this param from the $_GET array
  $limit = 3; // The number of results per page
  $maxpages = 10; // The number of pages for displaying in the pager
  $sql = "select * from item";
  $res = $db->limitQuery($sql, $from, $limit);
  $nrows = 0; // Alternative you could use $res->numRows()
  while ($row = $res->fetchrow()) {
    // XXX code for building the page here
  $data = DB_Pager::getData($from, $limit, $nrows, $maxpages);
  echo $nrows . '<br>';
  // XXX code for building the pager here

I found it strange, because this code always shows one page, beacuse of
the $nrows param in the getData call.

If I change the line

  $data = DB_Pager::getData($from, $limit, $nrows, $maxpages);


  $data = DB_Pager::getData($from, $limit, 12, $maxpages);

It works correctly (12 is the number of rows in the item table), it
gives me the right statistics for the next and previous pages, etc....

Maybe there is something I don't' understand, but with the suggested
usage, the pager is useless!!

Thanks for any hint.


Site Timeline