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

This is a discussion on PEAR::DB_Pager: a very strange USAGE!!!! within the PHP Language forums, part of the PHP Programming Forums category; HI, this is the usage code suggested by the author of PEAR::DB_Pager. <?php require_once 'DB/Pager.php'; $db = ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-19-2005
ProgDario
 
Posts: n/a
Default PEAR::DB_Pager: a very strange USAGE!!!!

HI,

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

<?php
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
(optional)
$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
$nrows++;
}
$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);

into

$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.

:)ario

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:48 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0