DB_Pager
| From: | Steen Rabøl | Date: | Tue, 09 Jul 2002 21:32:54 +0000 |
| Subject: | DB_Pager | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-7603@lists.php.net to get a copy of this message | ||
Hi
I don't get it...
In the latest version of db_pager there is a small sample, but....
If you use the limitQuery, then you only get xx records and then the call to
DB_Pager::getData() don't contain any usefull information. Small sample:
<?php
require_once 'DB/Pager.php';
$db = DB::connect("mysql" . "://" . "test" .":" .
"test" . "@" .
"localhost" . "/" . "test");
$from = (isset($_GET['from']) ? $_GET['from'] : 0);
$limit = 10;
$maxpages = 10;
$sql = "select * from test";
$res = $db->limitQuery($sql, $from, $limit);
$nrows = $res->numRows();
while ($row = $res->fetchrow(DB_FETCHMODE_ASSOC))
{
echo $row['id'] . " " . $row['text'] . "<br>";
}
$data = DB_Pager::getData($from, $limit, $nrows, $maxpages);
print "<pre>";
print_r($data);
print "</pre>";
?>
and the print_r output:
Array
(
[numpages] => 1
[firstpage] => 1
[lastpage] => 1
[pages] => Array
(
[1] => 0
)
[current] => 1
[maxpages] => 10
[prev] =>
[next] =>
[remain] => 0
[to] => 10
[numrows] => 10
[from] => 1
[limit] => 10
)
As you can see, the prev and nex is empty. There is more than 10 records in
the table ;-)
So the limitQuery() might not be a good choice, or am i missing the point ?
Best
Steen