[ Index ]
 

Code source de PHP PEAR 1.4.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/DB/ -> Pager.php (sommaire)

(pas de description)

Poids: 250 lignes (8 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 2 fichiers
 DB.php
 PEAR.php

Définit 1 class

DB_Pager:: (5 méthodes):
  DB_Pager()
  build()
  fetchRow()
  fetchInto()
  getData()


Classe: DB_Pager  - X-Ref

This class handles all the stuff needed for displaying paginated results
from a database query of Pear DB, in a very easy way.
Documentation and examples of use, can be found in:
http://vulcanonet.com/soft/pager/ (could be outdated)

IMPORTANT!
Since PEAR DB already support native row limit (more fast and avaible in
all the drivers), there is no more need to use $pager->build() or
the $pager->fetch*() methods.

Usage example:

< ?php
require_once 'DB/Pager.php';
$db = DB::connect('your DSN string');
$from = 0;   // The row to start to fetch from (you might want to get this
// param from the $_GET array
$limit = 10; // The number of results per page
$maxpages = 10; // The number of pages for displaying in the pager (optional)
$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);
// XXX code for building the pager here
? >

DB_Pager(&$res, $from, $limit, $numrows = null)   X-Ref
Constructor

param: object $res  A DB_result object from Pear_DB
param: int    $from  The row to start fetching
param: int    $limit  How many results per page
param: int    $numrows Pager will automatically

build()   X-Ref
Calculates all the data needed by Pager to work

return: mixed An assoc array with all the data (see getData)

fetchRow($mode=DB_FETCHMODE_DEFAULT)   X-Ref


fetchInto(&$arr, $mode=DB_FETCHMODE_DEFAULT)   X-Ref


getData($from, $limit, $numrows, $maxpages = false)   X-Ref
Pas de description



Généré le : Sun Feb 25 14:08:00 2007 par Balluche grâce à PHPXref 0.7