Location: PHPKode > scripts > Pagination > pagination/PaginationFactory.php
<?php
include_once("Pagination.php");
include_once("DBTypes.php");

/**
* class PaginationFactory
*
* { Description :- 
*	Factory Method is used to return the instance of Pagination class depending on the type of database based on the value
*   of $DBType varaible.  
* }
*
*/

class PaginationFactory
{
	/**
	* Method PaginationFactory::getInstanceOf()
	*
	* { Description :- 
	*	Factory Method is used to return the instance of Pagination class depending on the type of database based on the value
	*   of $DBType varaible.  
	*	
	*	Parameters :-
	*	$result -- ResultSet fetched from the database on query.
	*	$pageSize -- Number of rows to be displayed in a page.
	*	$conn -- Connection Handle.
	*	$numRows -- total rows returned after query on database.
	*	$resultPage -- current page to be displayed
	*	$DBType -- Database Type MSSQL or MySQL (This parameter is optional. Defaults to MySQL). 
	* }
	*/
	
	function getInstanceOf($result, $pageSize, $conn, $numRows, $resultPage, $DBType="")
	{
		switch($DBType)
		{
			case MYSQL:
			{
				return new MySqlPagination($result, $pageSize, $conn, $numRows, $resultPage);
				break;
			}
			
			case MSSQL:
			{
				return new MSSqlPagination($result, $pageSize, $conn, $numRows, $resultPage);
				break;
			}
			
			default:
				return new MySqlPagination($result, $pageSize, $conn, $numRows, $resultPage);
		}
	}
	
}
?>
Return current item: Pagination