<?php
/* project: Pager grid, file: pagergrid.php */
/* We want remember sorting and filtering. It will be stored in session. */
session_start();
//Include pclib framework
require 'pclib/pclib.php';
//Create pclib application
$app = new PCApp('demo');
$datasource = 'pdo_mysql://user:password@localhost/test';
//Tweaking of the pager.
function setMyPager($grid)
{
$pagerForm = new PCForm("tpl/pagerform.tpl", "sessform");
$grid->pager->setPageLen($pagerForm->values['pglen']);
$grid->pager->setPage($_GET['page'] ?: $pagerForm->values['page']);
$pagerForm->_page = $grid->pager->getValue('page');
$pagerForm->_maxpage = $grid->pager->getValue('maxpage');
$pagerForm->_pglen = $grid->pager->getValue('pglen');
$pagerForm->_pages = $grid->pager->getHtml('pages');
$grid->values['pager'] = $pagerForm;
}
$app->db = new PCDb($datasource);
$products = new PCGrid ("tpl/pagergrid.tpl");
$products->setQuery("select * from PRODUCTS");
setMyPager($products);
print $products;
?>
Elapsed time: 12.21 ms