apidoc
[ class tree: apidoc ] [ index: apidoc ] [ all elements ]

Class: DB_Pager

Source Location: /DB_Pager-0.7.2/Pager.php

Class Overview

PEAR
   |
   --DB_Pager

This class handles all the stuff needed for displaying paginated results from a database query of Pear DB, in a very easy way.


Author(s):

Version:

  • 0.7

Methods


Inherited Variables

Inherited Methods


Class Details

[line 63]
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 ? >



[ Top ]


Method Detail

DB_Pager (Constructor)   [line 78]

DB_Pager DB_Pager( &$res, int $from, int $limit, [int $numrows = null], object $res)

Constructor
  • Deprecated:

Parameters:

object   $res   —  A DB_result object from Pear_DB
int   $from   —  The row to start fetching
int   $limit   —  How many results per page
int   $numrows   —  Pager will automatically find this param if is not given. If your Pear_DB backend extension doesn't support numrows(), you can manually calculate it and supply later to the constructor
   &$res   — 

[ Top ]

build   [line 94]

mixed build( )

Calculates all the data needed by Pager to work
  • Return: An assoc array with all the data (see getData) or DB_Error on error
  • See: DB_Pager::getData
  • Deprecated:

[ Top ]

fetchInto   [line 127]

void fetchInto( &$arr, [ $mode = DB_FETCHMODE_DEFAULT])

  • Deprecated:

Parameters:

   &$arr   — 
   $mode   — 

[ Top ]

fetchRow   [line 115]

void fetchRow( [ $mode = DB_FETCHMODE_DEFAULT])

  • Deprecated:

Parameters:

   $mode   — 

[ Top ]

getData   [line 167]

void &getData( $from, $limit, $numrows, [ $maxpages = false])


Parameters:

   $from   — 
   $limit   — 
   $numrows   — 
   $maxpages   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:28:10 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.