From 1eaa6ca1775d335e2307d958c7f0ad27f7cd6807 Mon Sep 17 00:00:00 2001 From: "ctrlaltca@gmail.com" <> Date: Tue, 14 Feb 2012 08:13:27 +0000 Subject: further SqlMap optimizations; refs #337 --- .../Data/SqlMap/Configuration/TSqlMapStatement.php | 17 ++++++++++- .../Data/SqlMap/Statements/TMappedStatement.php | 34 ++++++++++++++++++---- .../Data/SqlMap/Statements/TPreparedStatement.php | 14 +++++++++ 3 files changed, 59 insertions(+), 6 deletions(-) (limited to 'framework/Data/SqlMap') diff --git a/framework/Data/SqlMap/Configuration/TSqlMapStatement.php b/framework/Data/SqlMap/Configuration/TSqlMapStatement.php index 3a62cbed..880e1057 100644 --- a/framework/Data/SqlMap/Configuration/TSqlMapStatement.php +++ b/framework/Data/SqlMap/Configuration/TSqlMapStatement.php @@ -295,7 +295,22 @@ class TSqlMapStatement extends TComponent public function __sleep() { - return array_diff(parent::__sleep(),array("\0TSqlMapStatement\0_resultMap")); + $cn = __CLASS__; + $exprops = array("\0$cn\0_resultMap"); + if (!$this->_parameterMapName) $exprops[] = "\0$cn\0_parameterMapName"; + if (!$this->_parameterMap) $exprops[] = "\0$cn\0_parameterMap"; + if (!$this->_parameterClassName) $exprops[] = "\0$cn\0_parameterClassName"; + if (!$this->_resultMapName) $exprops[] = "\0$cn\0_resultMapName"; + if (!$this->_resultMap) $exprops[] = "\0$cn\0_resultMap"; + if (!$this->_resultClassName) $exprops[] = "\0$cn\0_resultClassName"; + if (!$this->_cacheModelName) $exprops[] = "\0$cn\0_cacheModelName"; + if (!$this->_SQL) $exprops[] = "\0$cn\0_SQL"; + if (!$this->_listClass) $exprops[] = "\0$cn\0_listClass"; + if (!$this->_typeHandler) $exprops[] = "\0$cn\0_typeHandler"; + if (!$this->_extendStatement) $exprops[] = "\0$cn\0_extendStatement"; + if (!$this->_cache) $exprops[] = "\0$cn\0_cache"; + + return array_diff(parent::__sleep(),$exprops); } } diff --git a/framework/Data/SqlMap/Statements/TMappedStatement.php b/framework/Data/SqlMap/Statements/TMappedStatement.php index f58a6b39..982a8ce9 100644 --- a/framework/Data/SqlMap/Statements/TMappedStatement.php +++ b/framework/Data/SqlMap/Statements/TMappedStatement.php @@ -41,7 +41,7 @@ class TMappedStatement extends TComponent implements IMappedStatement /** * @var TPostSelectBinding[] post select statement queue. */ - private $_selectQueque=array(); + private $_selectQueue=array(); /** * @var boolean true when data is mapped to a particular row. @@ -506,9 +506,9 @@ class TMappedStatement extends TComponent implements IMappedStatement */ protected function executePostSelect($connection) { - while(count($this->_selectQueque)) + while(count($this->_selectQueue)) { - $postSelect = array_shift($this->_selectQueque); + $postSelect = array_shift($this->_selectQueue); $method = $postSelect->getMethod(); $statement = $postSelect->getStatement(); $property = $postSelect->getResultProperty()->getProperty(); @@ -869,7 +869,7 @@ class TMappedStatement extends TComponent implements IMappedStatement $postSelect->setMethod(self::QUERY_FOR_OBJECT); if(!$property->getLazyLoad()) - $this->_selectQueque[] = $postSelect; + $this->_selectQueue[] = $postSelect; } /** @@ -918,6 +918,21 @@ class TMappedStatement extends TComponent implements IMappedStatement $this->_IsRowDataFound = $dataFound; return $dataFound; } + + public function __wakeup() + { + parent::__wakeup(); + if (is_null($this->_selectQueue)) $this->_selectQueue = array(); + } + + public function __sleep() + { + $exprops = array(); $cn = __CLASS__; + if (!count($this->_selectQueue)) $exprops[] = "\0$cn\0_selectQueue"; + if (is_null($this->_groupBy)) $exprops[] = "\0$cn\0_groupBy"; + if (!$this->_IsRowDataFound) $exprops[] = "\0$cn\0_IsRowDataFound"; + return array_diff(parent::__sleep(),$exprops); + } } /** @@ -964,7 +979,7 @@ class TPostSelectBinding * @package System.Data.SqlMap.Statements * @since 3.1 */ -class TSqlMapObjectCollectionTree +class TSqlMapObjectCollectionTree extends TComponent { /** * @var array object graph as tree @@ -1133,6 +1148,15 @@ class TSqlMapObjectCollectionTree { return $this->_list; } + + public function __sleep() + { + $exprops = array(); $cn = __CLASS__; + if (!count($this->_tree)) $exprops[] = "\0$cn\0_tree"; + if (!count($this->_entries)) $exprops[] = "\0$cn\0_entries"; + if (!count($this->_list)) $exprops[] = "\0$cn\0_list"; + return array_diff(parent::__sleep(),$exprops); + } } /** diff --git a/framework/Data/SqlMap/Statements/TPreparedStatement.php b/framework/Data/SqlMap/Statements/TPreparedStatement.php index 372c9e88..4bd19c4e 100644 --- a/framework/Data/SqlMap/Statements/TPreparedStatement.php +++ b/framework/Data/SqlMap/Statements/TPreparedStatement.php @@ -39,5 +39,19 @@ class TPreparedStatement extends TComponent public function getParameterValues(){ return $this->_parameterValues; } public function setParameterValues($value){ $this->_parameterValues = $value; } + public function __wakeup() + { + parent::__wakeup(); + if (!$this->_parameterNames) $this->_parameterNames = new TList; + if (!$this->_parameterValues) $this->_parameterValues = new TMap; + } + + public function __sleep() + { + $exprops = array(); $cn = __CLASS__; + if (!$this->_parameterNames->getCount()) $exprops[] = "\0$cn\0_parameterNames"; + if (!$this->_parameterValues->getCount()) $exprops[] = "\0$cn\0_parameterValues"; + return array_diff(parent::__sleep(),$exprops); + } } -- cgit v1.2.3