Ryzom Account Management System  1.0
Public Member Functions | Private Attributes
Pagination Class Reference

Handles returning arrays based on a given pagenumber. More...

Public Member Functions

 __construct ($query, $db, $nrDisplayed, $resultClass, $params=array())
 Constructor.
 getLast ()
 return the number of the 'last' object attribute
 getCurrent ()
 return the number of the 'current' object attribute
 getElements ()
 return the elements array of the object
 getAmountOfRows ()
 return total amount of rows for the original query
 getLinks ($nrOfLinks)
 return the page links.

Private Attributes

 $element_array
 Array containing the elements that are extracted for that specific page number.
 $last
 The last page number.
 $current
 The current page number (read from $_GET['pagenum'])
 $amountOfRows
 Total amount of rows that a query would return (if no limits would be used)

Detailed Description

Handles returning arrays based on a given pagenumber.

By specifing a $_GET['pagenum'] or if not(page = 1 will be used) a few elements from a specific query will be returned. Not all elements have to be loaded into objects, only the elements needed for that specific page, this is a good thing performance wise. This is done by passign the query to the constructor and specifying how many you want to display.

Author:
Daan Janssens, mentored by Matthew Lagoe

Constructor & Destructor Documentation

__construct ( query,
db,
nrDisplayed,
resultClass,
params = array() 
)

Constructor.

will fetch the correct elements that match to a specific page (specified by the $_GET['pagenum'] variable). The query has to be passed as a string to the function that way it will only load the specific elements that are related to the pagenumber. The $params, parameter is optional and is used to pass the parameters for the query. The result class will be used to instantiate the found elements with, their set() function will be called. The class its getters can be later used to get the info out of the object.

Parameters:
$querythe query to be paginated
$dbthe db on which the query should be performed
$nrDisplayedthe amount of elements that should be displayed /page
$resultClassthe elements that should be returned should be of that specific class.
$paramsthe parameters used by the query (optional)

Member Function Documentation

return total amount of rows for the original query

Returns:
the total amount of rows for the original query

return the number of the 'current' object attribute

Returns:
the number of the current page

return the elements array of the object

Returns:
the elements of a specific page (these are instantiations of the class passed as parameter ($resultClass) to the constructor)
getLast ( )

return the number of the 'last' object attribute

Returns:
the number of the last page
getLinks ( nrOfLinks)

return the page links.

(for browsing the pages, placed under a table for example) the $nrOfLinks parameter specifies the amount of links you want to return. it will show the links closest to the current page on both sides (in case one side can't show more, it will show more on the other side)

Returns:
an array of integerswhich refer to the clickable pagenumbers for browsing other pages.

Field Documentation

$amountOfRows [private]

Total amount of rows that a query would return (if no limits would be used)

$current [private]

The current page number (read from $_GET['pagenum'])

$element_array [private]

Array containing the elements that are extracted for that specific page number.

$last [private]

The last page number.


The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables