From 3392e51b4edf84682b66ce9e32d00c1adb3205bb Mon Sep 17 00:00:00 2001 From: wei <> Date: Tue, 8 May 2007 07:49:50 +0000 Subject: Fixed sqlmap query with limit and offsets. --- .../Data/SqlMap/Configuration/TSqlMapStatement.php | 24 +++++++++++----------- .../Data/SqlMap/Statements/TMappedStatement.php | 6 ++++-- .../Data/SqlMap/Statements/TPreparedCommand.php | 12 +++++++++-- 3 files changed, 26 insertions(+), 16 deletions(-) (limited to 'framework/Data/SqlMap') diff --git a/framework/Data/SqlMap/Configuration/TSqlMapStatement.php b/framework/Data/SqlMap/Configuration/TSqlMapStatement.php index 5d2640e9..f5c43594 100644 --- a/framework/Data/SqlMap/Configuration/TSqlMapStatement.php +++ b/framework/Data/SqlMap/Configuration/TSqlMapStatement.php @@ -310,18 +310,6 @@ class TSqlMapSelect extends TSqlMapStatement public function setGenerate($value){ $this->_generate = $value; } } -/** - * TSqlMapDelete class corresponds to the element. - * - * @author Wei Zhuo - * @version $Id$ - * @package System.Data.SqlMap.Configuration - * @since 3.1 - */ -class TSqlMapDelete extends TSqlMapUpdate -{ -} - /** * TSqlMapInsert class corresponds to the element. * @@ -366,6 +354,18 @@ class TSqlMapUpdate extends TSqlMapStatement { } +/** + * TSqlMapDelete class corresponds to the element. + * + * @author Wei Zhuo + * @version $Id$ + * @package System.Data.SqlMap.Configuration + * @since 3.1 + */ +class TSqlMapDelete extends TSqlMapUpdate +{ +} + /** * TSqlMapSelect corresponds to the element. * diff --git a/framework/Data/SqlMap/Statements/TMappedStatement.php b/framework/Data/SqlMap/Statements/TMappedStatement.php index e56e73ce..db02857f 100644 --- a/framework/Data/SqlMap/Statements/TMappedStatement.php +++ b/framework/Data/SqlMap/Statements/TMappedStatement.php @@ -203,7 +203,7 @@ class TMappedStatement extends TComponent implements IMappedStatement */ public function executeQueryForList($connection, $parameter, $result=null, $skip=-1, $max=-1, $delegate=null) { - $sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter); + $sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter,$skip,$max); return $this->runQueryForList($connection, $parameter, $sql, $result, $skip, $max, $delegate); } @@ -228,7 +228,9 @@ class TMappedStatement extends TComponent implements IMappedStatement $registry=$this->getManager()->getTypeHandlers(); $list = $result instanceof ArrayAccess ? $result : $this->_statement->createInstanceOfListClass($registry); - $reader = $this->executeSQLQueryLimit($connection, $sql, $max, $skip); + $connection->setActive(true); + $reader = $sql->query(); + //$reader = $this->executeSQLQueryLimit($connection, $sql, $max, $skip); if(!is_null($delegate)) { foreach($reader as $row) diff --git a/framework/Data/SqlMap/Statements/TPreparedCommand.php b/framework/Data/SqlMap/Statements/TPreparedCommand.php index 7bb68c79..ff5fd6ff 100644 --- a/framework/Data/SqlMap/Statements/TPreparedCommand.php +++ b/framework/Data/SqlMap/Statements/TPreparedCommand.php @@ -10,6 +10,8 @@ * @package System.Data.SqlMap.Statements */ +Prado::using('System.Data.Common.TDbMetaData'); + /** * TPreparedCommand class. * @@ -20,11 +22,17 @@ */ class TPreparedCommand { - public function create(TSqlMapManager $manager, $connection, $statement, $parameterObject) + public function create(TSqlMapManager $manager, $connection, $statement, $parameterObject,$skip=null,$max=null) { $prepared = $statement->getSQLText()->getPreparedStatement($parameterObject); $connection->setActive(true); - $command = $connection->createCommand($prepared->getPreparedSql()); + $sql = $prepared->getPreparedSql(); + if($max!==null || $skip!==null) + { + $builder = TDbMetaData::getInstance($connection)->createCommandBuilder(); + $sql = $builder->applyLimitOffset($sql,$max,$skip); + } + $command = $connection->createCommand($sql); $this->applyParameterMap($manager, $command, $prepared, $statement, $parameterObject); return $command; } -- cgit v1.2.3