From 903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 Mon Sep 17 00:00:00 2001 From: ctrlaltca <> Date: Thu, 12 Jul 2012 11:21:01 +0000 Subject: standardize the use of unix eol; use svn properties to enforce native eol --- .../Data/SqlMap/Statements/TCachingStatement.php | 216 ++++++++++----------- 1 file changed, 108 insertions(+), 108 deletions(-) (limited to 'framework/Data/SqlMap/Statements/TCachingStatement.php') diff --git a/framework/Data/SqlMap/Statements/TCachingStatement.php b/framework/Data/SqlMap/Statements/TCachingStatement.php index 54664e37..cac84458 100644 --- a/framework/Data/SqlMap/Statements/TCachingStatement.php +++ b/framework/Data/SqlMap/Statements/TCachingStatement.php @@ -1,108 +1,108 @@ - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2012 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Id$ - * @package System.Data.SqlMap.Statements - */ - -/** - * TCacheingStatement class. - * - * @author Wei Zhuo - * @version $Id$ - * @package System.Data.SqlMap.Statements - * @since 3.1 - */ -class TCachingStatement extends TComponent implements IMappedStatement -{ - private $_mappedStatement; - - public function __construct(TMappedStatement $statement) - { - $this->_mappedStatement = $statement; - } - - public function getID() - { - return $this->_mappedStatement->getID(); - } - - public function getStatement() - { - return $this->_mappedStatement->getStatement(); - } - - public function getManager() - { - return $this->_mappedStatement->getManager(); - } - - public function executeQueryForMap($connection, $parameter,$keyProperty, $valueProperty=null, $skip=-1, $max=-1,$delegate=null) - { - $sql = $this->createCommand($connection, $parameter, $skip, $max); - $key = $this->getCacheKey(array(clone($sql), $keyProperty, $valueProperty,$skip, $max)); - $map = $this->getStatement()->getCache()->get($key); - if($map===null) - { - $map = $this->_mappedStatement->runQueryForMap( - $connection, $parameter, $sql, $keyProperty, $valueProperty, $delegate); - $this->getStatement()->getCache()->set($key, $map); - } - return $map; - } - - public function executeUpdate($connection, $parameter) - { - return $this->_mappedStatement->executeUpdate($connection, $parameter); - } - - public function executeInsert($connection, $parameter) - { - return $this->executeInsert($connection, $parameter); - } - - public function executeQueryForList($connection, $parameter, $result=null, $skip=-1, $max=-1, $delegate=null) - { - $sql = $this->createCommand($connection, $parameter, $skip, $max); - $key = $this->getCacheKey(array(clone($sql), $parameter, $skip, $max)); - $list = $this->getStatement()->getCache()->get($key); - if($list===null) - { - $list = $this->_mappedStatement->runQueryForList( - $connection, $parameter, $sql, $result, $delegate); - $this->getStatement()->getCache()->set($key, $list); - } - return $list; - } - - public function executeQueryForObject($connection, $parameter, $result=null) - { - $sql = $this->createCommand($connection, $parameter); - $key = $this->getCacheKey(array(clone($sql), $parameter)); - $object = $this->getStatement()->getCache()->get($key); - if($object===null) - { - $object = $this->_mappedStatement->runQueryForObject($connection, $sql, $result); - $this->getStatement()->getCache()->set($key, $object); - } - return $object; - } - - protected function getCacheKey($object) - { - $cacheKey = new TSqlMapCacheKey($object); - return $cacheKey->getHash(); - } - - protected function createCommand($connection, $parameter, $skip=null, $max=null) - { - return $this->_mappedStatement->getCommand()->create($this->getManager(), - $connection, $this->getStatement(), $parameter, $skip, $max); - } -} - + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2012 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + * @package System.Data.SqlMap.Statements + */ + +/** + * TCacheingStatement class. + * + * @author Wei Zhuo + * @version $Id$ + * @package System.Data.SqlMap.Statements + * @since 3.1 + */ +class TCachingStatement extends TComponent implements IMappedStatement +{ + private $_mappedStatement; + + public function __construct(TMappedStatement $statement) + { + $this->_mappedStatement = $statement; + } + + public function getID() + { + return $this->_mappedStatement->getID(); + } + + public function getStatement() + { + return $this->_mappedStatement->getStatement(); + } + + public function getManager() + { + return $this->_mappedStatement->getManager(); + } + + public function executeQueryForMap($connection, $parameter,$keyProperty, $valueProperty=null, $skip=-1, $max=-1,$delegate=null) + { + $sql = $this->createCommand($connection, $parameter, $skip, $max); + $key = $this->getCacheKey(array(clone($sql), $keyProperty, $valueProperty,$skip, $max)); + $map = $this->getStatement()->getCache()->get($key); + if($map===null) + { + $map = $this->_mappedStatement->runQueryForMap( + $connection, $parameter, $sql, $keyProperty, $valueProperty, $delegate); + $this->getStatement()->getCache()->set($key, $map); + } + return $map; + } + + public function executeUpdate($connection, $parameter) + { + return $this->_mappedStatement->executeUpdate($connection, $parameter); + } + + public function executeInsert($connection, $parameter) + { + return $this->executeInsert($connection, $parameter); + } + + public function executeQueryForList($connection, $parameter, $result=null, $skip=-1, $max=-1, $delegate=null) + { + $sql = $this->createCommand($connection, $parameter, $skip, $max); + $key = $this->getCacheKey(array(clone($sql), $parameter, $skip, $max)); + $list = $this->getStatement()->getCache()->get($key); + if($list===null) + { + $list = $this->_mappedStatement->runQueryForList( + $connection, $parameter, $sql, $result, $delegate); + $this->getStatement()->getCache()->set($key, $list); + } + return $list; + } + + public function executeQueryForObject($connection, $parameter, $result=null) + { + $sql = $this->createCommand($connection, $parameter); + $key = $this->getCacheKey(array(clone($sql), $parameter)); + $object = $this->getStatement()->getCache()->get($key); + if($object===null) + { + $object = $this->_mappedStatement->runQueryForObject($connection, $sql, $result); + $this->getStatement()->getCache()->set($key, $object); + } + return $object; + } + + protected function getCacheKey($object) + { + $cacheKey = new TSqlMapCacheKey($object); + return $cacheKey->getHash(); + } + + protected function createCommand($connection, $parameter, $skip=null, $max=null) + { + return $this->_mappedStatement->getCommand()->create($this->getManager(), + $connection, $this->getStatement(), $parameter, $skip, $max); + } +} + -- cgit v1.2.3