From 5cb8bf3a2d0f7d7b9b0b5907a80aee85a8c6f2d9 Mon Sep 17 00:00:00 2001 From: mikl <> Date: Thu, 31 Jul 2008 13:07:13 +0000 Subject: Fixed #893: Added page parameter to queryForPagedList() --- HISTORY | 3 ++- demos/sqlmap/protected/pages/Manual/DataMapperAPI.page | 14 +++++++++++--- framework/Data/SqlMap/DataMapper/TSqlMapPagedList.php | 10 ++++++---- framework/Data/SqlMap/TSqlMapGateway.php | 10 ++++++---- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/HISTORY b/HISTORY index 8929c5de..9a5ea7ab 100644 --- a/HISTORY +++ b/HISTORY @@ -9,10 +9,11 @@ BUG: Ticket#859 - errorhandler error (stever) BUG: Ticket#860 - Prado::localize() bug (japplegame) BUG: Ticket#870 - Callback with redirect breaks lifecycle of page (stever) BUG: Ticket#872 - use PATH_SEPARATOR in phpunit.php (fragmaster b) +BUG: Ticket#886 - TSimpleDateFormatter: One month offset in time stamp with date pattern "yyyy" (Knut) ENH: Added Prado.Validation.validateControl(id) on client side to validate a specific control (Michael) ENH: Added MessageSource_Database to I18N (uses TDbConnection) (Michael) +ENH: Ticket#893 - Added page parameter to queryForPagedList() to specify the initial page to load (Michael) CHG: Ticket#844 - Upgraded TinyMCE to 3.1.0.1 (Christophe) -BUG: Ticket#886 - TSimpleDateFormatter: One month offset in time stamp with date pattern "yyyy" (Knut) Version 3.1.2 April 21, 2008 ============================ diff --git a/demos/sqlmap/protected/pages/Manual/DataMapperAPI.page b/demos/sqlmap/protected/pages/Manual/DataMapperAPI.page index 8f0b66a4..fb9552a3 100644 --- a/demos/sqlmap/protected/pages/Manual/DataMapperAPI.page +++ b/demos/sqlmap/protected/pages/Manual/DataMapperAPI.page @@ -9,7 +9,7 @@ the DataMapper framework. The DataMapper API methods are shown below.

public function queryForObject($statementName, $parameter=null, $result=null); public function queryForList($statementName, $parameter=null, $result=null, $skip=-1, $max=-1); -public function queryForPagedList($statementName, $parameter=null, $pageSize=10); +public function queryForPagedList($statementName, $parameter=null, $pageSize=10, $page=0); public function queryForMap($statementName, $parameter=null, $keyProperty=null, $valueProperty=null); public function insert($statementName, $parameter=null) @@ -78,7 +78,7 @@ point) and the maximum number to return.

QueryForPagedList

- public function queryForPagedList($statementName, $parameter=null, $pageSize=10); + public function queryForPagedList($statementName, $parameter=null, $pageSize=10, $page);

We live in an age of information overflow. A database query often returns more @@ -107,6 +107,14 @@ want to use a stored procedure or your own query that uses $skip and $max as parameters in queryForList. +

Tip: +The $page parameter was introduced in 3.1.3. Before there was an additional +query to always fetch the data for page 0 on object creation. Since this +might be a problem in performance critical situations with 3.1.2, you might be better +of also using queryForList with $skip and $max instead. +
+ +

QueryForMap

public function queryForMap($statementName, $parameter=null, @@ -159,4 +167,4 @@ catch } - \ No newline at end of file + diff --git a/framework/Data/SqlMap/DataMapper/TSqlMapPagedList.php b/framework/Data/SqlMap/DataMapper/TSqlMapPagedList.php index a52e9a39..b3a88653 100644 --- a/framework/Data/SqlMap/DataMapper/TSqlMapPagedList.php +++ b/framework/Data/SqlMap/DataMapper/TSqlMapPagedList.php @@ -41,12 +41,13 @@ class TSqlMapPagedList extends TPagedList * @param mixed query parameters * @param int page size * @param mixed delegate for each data row retrieved. + * @param int number of page to fetch on initialization */ - public function __construct(IMappedStatement $statement,$parameter, $pageSize, $delegate=null) + public function __construct(IMappedStatement $statement,$parameter, $pageSize, $delegate=null, $page=0) { parent::__construct(); parent::setCustomPaging(true); - $this->initialize($statement,$parameter, $pageSize); + $this->initialize($statement,$parameter, $pageSize, $page); $this->_delegate=$delegate; } @@ -55,14 +56,15 @@ class TSqlMapPagedList extends TPagedList * @param IMappedStatement SqlMap statement. * @param mixed query parameters * @param int page size. + * @param int number of page. */ - protected function initialize($statement, $parameter, $pageSize) + protected function initialize($statement, $parameter, $pageSize, $page) { $this->_statement = $statement; $this->_parameter = $parameter; $this->setPageSize($pageSize); $this->attachEventHandler('OnFetchData', array($this, 'fetchDataFromStatement')); - $this->gotoPage(0); + $this->gotoPage($page); } /** diff --git a/framework/Data/SqlMap/TSqlMapGateway.php b/framework/Data/SqlMap/TSqlMapGateway.php index fcd7d216..dd7c2069 100644 --- a/framework/Data/SqlMap/TSqlMapGateway.php +++ b/framework/Data/SqlMap/TSqlMapGateway.php @@ -122,12 +122,13 @@ class TSqlMapGateway extends TComponent * @param string The name of the sql statement to execute. * @param mixed The object used to set the parameters in the SQL. * @param integer The maximum number of objects to store in each page. + * @param integer The number of the page to initially load into the list. * @return TPagedList A PaginatedList of beans containing the rows. */ - public function queryForPagedList($statementName, $parameter=null, $pageSize=10) + public function queryForPagedList($statementName, $parameter=null, $pageSize=10, $page=0) { $statement = $this->getSqlMapManager()->getMappedStatement($statementName); - return new TSqlMapPagedList($statement, $parameter, $pageSize); + return new TSqlMapPagedList($statement, $parameter, $pageSize, null, $page); } /** @@ -142,12 +143,13 @@ class TSqlMapGateway extends TComponent * @param callback Row delegate handler, a valid callback required. * @param mixed The object used to set the parameters in the SQL. * @param integer The maximum number of objects to store in each page. + * @param integer The number of the page to initially load into the list. * @return TPagedList A PaginatedList of beans containing the rows. */ - public function queryForPagedListWithRowDelegate($statementName,$delegate, $parameter=null, $pageSize=10) + public function queryForPagedListWithRowDelegate($statementName,$delegate, $parameter=null, $pageSize=10, $page=0) { $statement = $this->getSqlMapManager()->getMappedStatement($statementName); - return new TSqlMapPagedList($statement, $parameter, $pageSize, $delegate); + return new TSqlMapPagedList($statement, $parameter, $pageSize, $delegate,$page); } -- cgit v1.2.3