sql 
[ doc home ] [ class tree: sql ] [ index: sql ] [ all elements ]

Class: IsterSqlPager

Source Location: /IsterSqlPager.php

Class Overview

IsterObject
   |
   --IsterSqlPager

This class provides methods to build a pager for large SQL result sets.


Author(s): Ingo Schramm   

Copyright: Copyright (c) 2005 Ister.ORG Ingo Schramm

Methods


Inherited Constants

Inherited Variables

Inherited Methods

Class: IsterObject

IsterObject::IsterObject()
Constructor
IsterObject::abstractMethodError()
Report attempt to call an abstract method.
IsterObject::addLogger()
Add an IsterLogger to process log messages.
IsterObject::deleteLogger()
Delete an already registered IsterLogger.
IsterObject::getLoggerNames()
Fetch the names of all currently registered IsterLoggers.
IsterObject::getMem()
Return maximum amount of memory an application has allocated at this point.
IsterObject::log()
Trigger a log message.
IsterObject::passPHPmessage()
Catch PHP E_WARNING and E_NOTICE messages.
IsterObject::serialize()
Serialize the object.
IsterObject::setLogLocal()
Set logging local for the current object.
IsterObject::setupLogger()
Setup a logger.
IsterObject::triggerError()
Alias for log();
IsterObject::unserialize()
Unserialize the object.
IsterObject::__sleep()
Executed prior to serialize().
IsterObject::__wakeup()
Executed prior to unserialize().

Class Details

This class provides methods to build a pager for large SQL result sets.

The constructor expects an already configured IsterSQLFunction object. This object is passed by reference. All queries will be executed on this object. To fetch the rows of a page, you have to call IsterSQLFunction::fetchObject() on this function object after you have called IsterSqlPager::getNextPage() or IsterSqlPager::getRandomPage().


copyright:  Copyright (c) 2005 Ister.ORG Ingo Schramm
author:  Ingo Schramm


[ Top ]


Class Methods


constructor IsterSqlPager

boolean IsterSqlPager( object IsterSQLFunction &$sqlfunction)

Constructor

Parameters:

object IsterSQLFunction   &$sqlfunction  

[ Top ]

method countPages

integer countPages( [integer $rows = 0])

Count the pages in the current result set.

return:  Number of pages, false on error.

Parameters:

integer   $rows  

[ Top ]

method getNextPage

boolean getNextPage( )

Let the passed IsterSQLFunction object execute the query to fetch the next page.

[ Top ]

method getPrevNext

array getPrevNext( integer $page, [integer $first = 1])

Parameters:

integer   $page  
integer   $first  

[ Top ]

method getRandomPage

boolean getRandomPage( integer $page)

Let the passed IsterSQLFunction object fetch a single page randomly.

Parameters:

integer   $page   Number of the page.

[ Top ]

method getWindow

array getWindow( integer $page)

Provide a window for very large result sets.

For very large result sets compute a window to select a subset of $windowsize pages around a given page; for odd windowsizes, page is the center (when possible); the window is returned as an array of page numbers.


Parameters:

integer   $page   Number of the page in the center of the window.

[ Top ]

method pagesLeft

boolean pagesLeft( )

Check whether pages are left in the current result set.

[ Top ]

method reset

boolean reset( )

Reset the pager.

[ Top ]

method setLimitFunction

boolean setLimitFunction( string $func)

Set the SQL function to execute a limited query.

  1. $func = "%query LIMIT %limit OFFSET %offset"; // postgresql
  2. $func = "%query LIMIT %offset, %limit";


see:  IsterSQLFunction

Parameters:

string   $func  

[ Top ]

method setQuery

boolean setQuery( string $query, [array $args = null], [string $test = null], [string $testcol = null])

Set the query or function to get a result set.

You may pass an optional test query to determine how many rows and pages will be returned by the query. If no such test is given, the query will be used. Otherwise, if a test query and a test column is given, the first row of the result set of the test query will be read and then the value of the test column will be treated as an integer counting the number of rows of the result set of the main query to execute.


Parameters:

string   $query  
array   $args  
string   $test  
string   $testcol  

[ Top ]

method setRowsPP

integer setRowsPP( integer $int)

Set the number of rows per page.

The default number of rows per page is 10.


return:  Old number of rows.

Parameters:

integer   $int  

[ Top ]

method setWindowSize

integer setWindowSize( integer $size)

Set the window size.

The default window size is 11.


return:  Old window size.
see:  IsterSqlPager::getWindow()

Parameters:

integer   $size   Set number of pages in the window.

[ Top ]


Documentation generated on Tue, 20 Dec 2005 11:21:18 +0100 by phpDocumentor 1.3.0RC4