Re: Re: Limited db paging with datagrid
| From: | daniel at electroteque dot org | Date: | Wed, 05 Jan 2005 01:39:34 +0000 |
| Subject: | Re: Re: Limited db paging with datagrid | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-16606@lists.php.net to get a copy of this message | ||
>
>
> $result = $db->query("SELECT COUNT(*) AS count FROM users");
> $record = $result->fetchRow();
>
> $result = $db->query("SELECT * FROM users LIMIT 20");
> $dg->bind($result);
>
> $dg->pager->_totalItems = $record['count'];
>
>
> And if you don't like any of these ideas, just create your own paging
> based on a count query.
>
> Hope this helps and let me know what your solution is
>
I'll give this a go, I had a look at creating drivers for the pager class,
getting there although icouldnt work out how to createw the classname dynamically but also call a
static method becauseits returning an array, maybe I could store the array in the object though ?
require_once 'Pager/Pager.php';
class Pager_Wrapper extends Pager
{
function Pager_Wrapper($driver,&$db,$query, $pagerOptions)
{
}
function getData($driver,&$db,$query, $pagerOptions)
{
if (@require_once('Pager/Wrapper/'.$driver.'.php')) {
$class = 'Pager_Wrapper_'.$driver;
if (class_exists($class)) {
$pager = new $class($db,$query, $pagerOptions);
return $pager->getData($db,$query, $pagerOptions);
}
} else {
return new PEAR_Error('Invalid driver');
}
}
}
Dan
(need to finding a datagrid and custom paging solution quickly :|)