This is the API docs for LemonStand V1, which has been discontinued. LemonStand is now a cloud based platform, available at lemonstand.com.

LemonStand API

Phpr_Pagination class

Defined in /phproad/modules/phpr/classes/phpr_pagination.php, lines 16-242
Author LemonStand eCommerce Inc.
Allows to paginate records, including database models. Phpr_Pagination is an general purpose class allowing to paginate a list of records, including database models. Usually objects of this class are created automatically with Db_ActiveRecord::paginate() method. Below is a typical usage of the pagination object:
$pagination = $products->paginate(0, 10);
After obtaining the pagination object you can extract the number of pages from this object and generate pagination markup.

See Also

Public methods

Method Description Defined By
getCurrentPageIndex() returns a zero-based index of the current page. Phpr_Pagination
getFirstPageRowIndex() returns an index of the first row on the current page. Phpr_Pagination
getLastPageRowIndex() returns an index of the last row on the current page. Phpr_Pagination
getPageCount() returns the total number of pages. Phpr_Pagination
getPageSize() returns the number of rows on a single page. Phpr_Pagination
getRowCount() returns the total number of rows. Phpr_Pagination
isFirstPage() determines whether the current page is first. Phpr_Pagination
isLastPage() determines whether the current page is last. Phpr_Pagination
limitActiveRecord() applies pagination to an Db_ActiveRecord object. Phpr_Pagination
setCurrentPageIndex() sets a zero-based index of a current page. Phpr_Pagination
setPageSize() sets the number of rows on a single page. Phpr_Pagination
setRowCount() sets the total number of rows. Phpr_Pagination
__construct() creates a new object of Phpr_Pagination class. Phpr_Pagination

Method details

getCurrentPageIndex() method

public integer getCurrentPageIndex()
{return} integer returns the page index.
Returns a zero-based index of the current page.

getFirstPageRowIndex() method

public integer getFirstPageRowIndex()
{return} integer returns the row index.
Returns an index of the first row on the current page.

getLastPageRowIndex() method

public integer getLastPageRowIndex()
{return} integer returns the row index.
Returns an index of the last row on the current page.

getPageCount() method

public integer getPageCount()
{return} integer returns the total number of pages.
Returns the total number of pages.

getPageSize() method

public integer getPageSize()
{return} integer returns the number of rows on a single page.
Returns the number of rows on a single page. The number of rows (page size) can be set in the object constructor or with setPageSize() method.

getRowCount() method

public integer getRowCount()
{return} integer returns the total number of rows.
Returns the total number of rows. The total number of rows should be previously set with setRowCount() method.

isFirstPage() method

public boolean isFirstPage()
{return} boolean returns TRUE if the current page is first. Returns FALSE otherwise.
Determines whether the current page is first.

isLastPage() method

public boolean isLastPage()
{return} boolean returns TRUE if the current page is last. Returns FALSE otherwise.
Determines whether the current page is last.

limitActiveRecord() method

public void limitActiveRecord(Db_ActiveRecord $model)
$model Db_ActiveRecord specifies the model object to limit.
Applies pagination to an Db_ActiveRecord object. This method should be called before the model's Db_ActiveRecord::find_all() method is called. Db_ActiveRecord class has a more convenient method for applying pagination - paginate().

setCurrentPageIndex() method

public integer setCurrentPageIndex(integer $value)
$value integer specifies the zero-based page index.
{return} integer returns the new page index.
Sets a zero-based index of a current page. Use this method to switch the pagination to another page before you call limitActiveRecord() method. The method returns the new page index. This value can differ from the passed value if case if the passed value exceeds the maximum number of pages or less than zero.

setPageSize() method

public void setPageSize(integer $value)
$value integer specifies the number of rows on a single page.
Sets the number of rows on a single page.

setRowCount() method

public void setRowCount(integer $row_count)
$row_count integer specifies the total number of rows.
Sets the total number of rows. This method should be called before the limitActiveRecord() method call. If you are working with Db_ActiveRecord objects, you can obtain the total number of rows with Db_ActiveRecord::requestRowCount() method. Db_ActiveRecord::paginate() method does this work automatically.

__construct() method

public Phpr_Pagination __construct(integer $page_size=20)
$page_size integer specifies the page size (number of records per page).
{return} Phpr_Pagination returns the pagination object.
Creates a new object of Phpr_Pagination class.