@@ -40,6 +40,7 @@ discard block |
||
| 40 | 40 | * @param int page size |
| 41 | 41 | * @param mixed delegate for each data row retrieved. |
| 42 | 42 | * @param int number of page to fetch on initialization |
| 43 | + * @param integer $pageSize |
|
| 43 | 44 | */ |
| 44 | 45 | public function __construct(IMappedStatement $statement,$parameter, $pageSize, $delegate=null, $page=0) |
| 45 | 46 | { |
@@ -55,6 +56,8 @@ discard block |
||
| 55 | 56 | * @param mixed query parameters |
| 56 | 57 | * @param int page size. |
| 57 | 58 | * @param int number of page. |
| 59 | + * @param IMappedStatement $statement |
|
| 60 | + * @param integer $page |
|
| 58 | 61 | */ |
| 59 | 62 | protected function initialize($statement, $parameter, $pageSize, $page) |
| 60 | 63 | { |
@@ -129,28 +129,24 @@ |
||
| 129 | 129 | { |
| 130 | 130 | $param->setData($data); |
| 131 | 131 | $this->_nextPageList = null; |
| 132 | - } |
|
| 133 | - else |
|
| 132 | + } else |
|
| 134 | 133 | { |
| 135 | 134 | $param->setData(array_slice($data, 0, $pageSize)); |
| 136 | 135 | $this->_nextPageList = array_slice($data, $pageSize-1,$total); |
| 137 | 136 | } |
| 138 | - } |
|
| 139 | - else |
|
| 137 | + } else |
|
| 140 | 138 | { |
| 141 | 139 | if($total <= $pageSize) |
| 142 | 140 | { |
| 143 | 141 | $this->_prevPageList = array_slice($data, 0, $total); |
| 144 | 142 | $param->setData(array()); |
| 145 | 143 | $this->_nextPageList = null; |
| 146 | - } |
|
| 147 | - else if($total <= $pageSize*2) |
|
| 144 | + } else if($total <= $pageSize*2) |
|
| 148 | 145 | { |
| 149 | 146 | $this->_prevPageList = array_slice($data, 0, $pageSize); |
| 150 | 147 | $param->setData(array_slice($data, $pageSize, $total)); |
| 151 | 148 | $this->_nextPageList = null; |
| 152 | - } |
|
| 153 | - else |
|
| 149 | + } else |
|
| 154 | 150 | { |
| 155 | 151 | $this->_prevPageList = array_slice($data, 0, $pageSize); |
| 156 | 152 | $param->setData(array_slice($data, $pageSize, $pageSize)); |
@@ -41,11 +41,11 @@ discard block |
||
| 41 | 41 | * @param mixed delegate for each data row retrieved. |
| 42 | 42 | * @param int number of page to fetch on initialization |
| 43 | 43 | */ |
| 44 | - public function __construct(IMappedStatement $statement,$parameter, $pageSize, $delegate=null, $page=0) |
|
| 44 | + public function __construct(IMappedStatement $statement, $parameter, $pageSize, $delegate=null, $page=0) |
|
| 45 | 45 | { |
| 46 | 46 | parent::__construct(); |
| 47 | 47 | parent::setCustomPaging(true); |
| 48 | - $this->initialize($statement,$parameter, $pageSize, $page); |
|
| 48 | + $this->initialize($statement, $parameter, $pageSize, $page); |
|
| 49 | 49 | $this->_delegate=$delegate; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | protected function initialize($statement, $parameter, $pageSize, $page) |
| 60 | 60 | { |
| 61 | - $this->_statement = $statement; |
|
| 62 | - $this->_parameter = $parameter; |
|
| 61 | + $this->_statement=$statement; |
|
| 62 | + $this->_parameter=$parameter; |
|
| 63 | 63 | $this->setPageSize($pageSize); |
| 64 | 64 | $this->attachEventHandler('OnFetchData', array($this, 'fetchDataFromStatement')); |
| 65 | 65 | $this->gotoPage($page); |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | protected function fetchDataFromStatement($sender, $param) |
| 82 | 82 | { |
| 83 | - $limit = $this->getOffsetAndLimit($param); |
|
| 84 | - $connection = $this->_statement->getManager()->getDbConnection(); |
|
| 85 | - $data = $this->_statement->executeQueryForList($connection, |
|
| 83 | + $limit=$this->getOffsetAndLimit($param); |
|
| 84 | + $connection=$this->_statement->getManager()->getDbConnection(); |
|
| 85 | + $data=$this->_statement->executeQueryForList($connection, |
|
| 86 | 86 | $this->_parameter, null, $limit[0], $limit[1], $this->_delegate); |
| 87 | 87 | $this->populateData($param, $data); |
| 88 | 88 | } |
@@ -112,49 +112,49 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | protected function populateData($param, $data) |
| 114 | 114 | { |
| 115 | - $total = $data instanceof TList ? $data->getCount() : count($data); |
|
| 116 | - $pageSize = $this->getPageSize(); |
|
| 115 | + $total=$data instanceof TList ? $data->getCount() : count($data); |
|
| 116 | + $pageSize=$this->getPageSize(); |
|
| 117 | 117 | if($total < 1) |
| 118 | 118 | { |
| 119 | 119 | $param->setData($data); |
| 120 | - $this->_prevPageList = null; |
|
| 121 | - $this->_nextPageList = null; |
|
| 120 | + $this->_prevPageList=null; |
|
| 121 | + $this->_nextPageList=null; |
|
| 122 | 122 | return; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | if($param->getNewPageIndex() < 1) |
| 126 | 126 | { |
| 127 | - $this->_prevPageList = null; |
|
| 127 | + $this->_prevPageList=null; |
|
| 128 | 128 | if($total <= $pageSize) |
| 129 | 129 | { |
| 130 | 130 | $param->setData($data); |
| 131 | - $this->_nextPageList = null; |
|
| 131 | + $this->_nextPageList=null; |
|
| 132 | 132 | } |
| 133 | 133 | else |
| 134 | 134 | { |
| 135 | 135 | $param->setData(array_slice($data, 0, $pageSize)); |
| 136 | - $this->_nextPageList = array_slice($data, $pageSize-1,$total); |
|
| 136 | + $this->_nextPageList=array_slice($data, $pageSize - 1, $total); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | else |
| 140 | 140 | { |
| 141 | 141 | if($total <= $pageSize) |
| 142 | 142 | { |
| 143 | - $this->_prevPageList = array_slice($data, 0, $total); |
|
| 143 | + $this->_prevPageList=array_slice($data, 0, $total); |
|
| 144 | 144 | $param->setData(array()); |
| 145 | - $this->_nextPageList = null; |
|
| 145 | + $this->_nextPageList=null; |
|
| 146 | 146 | } |
| 147 | - else if($total <= $pageSize*2) |
|
| 147 | + else if($total <= $pageSize * 2) |
|
| 148 | 148 | { |
| 149 | - $this->_prevPageList = array_slice($data, 0, $pageSize); |
|
| 149 | + $this->_prevPageList=array_slice($data, 0, $pageSize); |
|
| 150 | 150 | $param->setData(array_slice($data, $pageSize, $total)); |
| 151 | - $this->_nextPageList = null; |
|
| 151 | + $this->_nextPageList=null; |
|
| 152 | 152 | } |
| 153 | 153 | else |
| 154 | 154 | { |
| 155 | - $this->_prevPageList = array_slice($data, 0, $pageSize); |
|
| 155 | + $this->_prevPageList=array_slice($data, 0, $pageSize); |
|
| 156 | 156 | $param->setData(array_slice($data, $pageSize, $pageSize)); |
| 157 | - $this->_nextPageList = array_slice($data, $pageSize*2, $total-$pageSize*2); |
|
| 157 | + $this->_nextPageList=array_slice($data, $pageSize * 2, $total - $pageSize * 2); |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | protected function getOffsetAndLimit($param) |
| 168 | 168 | { |
| 169 | - $index = $param->getNewPageIndex(); |
|
| 170 | - $pageSize = $this->getPageSize(); |
|
| 171 | - return $index < 1 ? array($index, $pageSize*2) : array(($index-1)*$pageSize, $pageSize*3); |
|
| 169 | + $index=$param->getNewPageIndex(); |
|
| 170 | + $pageSize=$this->getPageSize(); |
|
| 171 | + return $index < 1 ? array($index, $pageSize * 2) : array(($index - 1) * $pageSize, $pageSize * 3); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -40,6 +40,7 @@ discard block |
||
| 40 | 40 | * @param mixed The object used to set the parameters in the SQL. |
| 41 | 41 | * @param string The property of the result object to be used as the key. |
| 42 | 42 | * @param string The property of the result object to be used as the value (or null) |
| 43 | + * @param TDbConnection $connection |
|
| 43 | 44 | * @return TMap A map of object containing the rows keyed by <tt>$keyProperty</tt>. |
| 44 | 45 | */ |
| 45 | 46 | public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty=null); |
@@ -50,6 +51,7 @@ discard block |
||
| 50 | 51 | * number of row effected. |
| 51 | 52 | * @param IDbConnection database connection to execute the query |
| 52 | 53 | * @param mixed The object used to set the parameters in the SQL. |
| 54 | + * @param TDbConnection $connection |
|
| 53 | 55 | * @return integer The number of row effected. |
| 54 | 56 | */ |
| 55 | 57 | public function executeUpdate($connection, $parameter); |
@@ -62,6 +64,7 @@ discard block |
||
| 62 | 64 | * @param TList A list to populate the result with. |
| 63 | 65 | * @param integer The number of rows to skip over. |
| 64 | 66 | * @param integer The maximum number of rows to return. |
| 67 | + * @param TDbConnection $connection |
|
| 65 | 68 | * @return TList A TList of result objects. |
| 66 | 69 | */ |
| 67 | 70 | public function executeQueryForList($connection, $parameter, $result=null, $skip=-1, $max=-1); |
@@ -73,6 +76,7 @@ discard block |
||
| 73 | 76 | * @param IDbConnection database connection to execute the query |
| 74 | 77 | * @param mixed The object used to set the parameters in the SQL. |
| 75 | 78 | * @param object The result object. |
| 79 | + * @param TDbConnection $connection |
|
| 76 | 80 | * @return object result. |
| 77 | 81 | */ |
| 78 | 82 | public function executeQueryForObject($connection,$parameter, $result=null); |
@@ -75,6 +75,6 @@ |
||
| 75 | 75 | * @param object The result object. |
| 76 | 76 | * @return object result. |
| 77 | 77 | */ |
| 78 | - public function executeQueryForObject($connection,$parameter, $result=null); |
|
| 78 | + public function executeQueryForObject($connection, $parameter, $result=null); |
|
| 79 | 79 | } |
| 80 | 80 | |
@@ -97,6 +97,10 @@ |
||
| 97 | 97 | return $cacheKey->getHash(); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | + /** |
|
| 101 | + * @param integer $skip |
|
| 102 | + * @param integer $max |
|
| 103 | + */ |
|
| 100 | 104 | protected function createCommand($connection, $parameter, $skip=null, $max=null) |
| 101 | 105 | { |
| 102 | 106 | return $this->_mappedStatement->getCommand()->create($this->getManager(), |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | public function __construct(TMappedStatement $statement) |
| 24 | 24 | { |
| 25 | - $this->_mappedStatement = $statement; |
|
| 25 | + $this->_mappedStatement=$statement; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | public function getID() |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | return $this->_mappedStatement->getManager(); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public function executeQueryForMap($connection, $parameter,$keyProperty, $valueProperty=null, $skip=-1, $max=-1,$delegate=null) |
|
| 43 | + public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty=null, $skip=-1, $max=-1, $delegate=null) |
|
| 44 | 44 | { |
| 45 | - $sql = $this->createCommand($connection, $parameter, $skip, $max); |
|
| 46 | - $key = $this->getCacheKey(array(clone($sql), $keyProperty, $valueProperty,$skip, $max)); |
|
| 47 | - $map = $this->getStatement()->getCache()->get($key); |
|
| 45 | + $sql=$this->createCommand($connection, $parameter, $skip, $max); |
|
| 46 | + $key=$this->getCacheKey(array(clone($sql), $keyProperty, $valueProperty, $skip, $max)); |
|
| 47 | + $map=$this->getStatement()->getCache()->get($key); |
|
| 48 | 48 | if($map===null) |
| 49 | 49 | { |
| 50 | - $map = $this->_mappedStatement->runQueryForMap( |
|
| 51 | - $connection, $parameter, $sql, $keyProperty, $valueProperty, $delegate); |
|
| 50 | + $map=$this->_mappedStatement->runQueryForMap( |
|
| 51 | + $connection, $parameter, $sql, $keyProperty, $valueProperty, $delegate); |
|
| 52 | 52 | $this->getStatement()->getCache()->set($key, $map); |
| 53 | 53 | } |
| 54 | 54 | return $map; |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | public function executeQueryForList($connection, $parameter, $result=null, $skip=-1, $max=-1, $delegate=null) |
| 68 | 68 | { |
| 69 | - $sql = $this->createCommand($connection, $parameter, $skip, $max); |
|
| 70 | - $key = $this->getCacheKey(array(clone($sql), $parameter, $skip, $max)); |
|
| 71 | - $list = $this->getStatement()->getCache()->get($key); |
|
| 69 | + $sql=$this->createCommand($connection, $parameter, $skip, $max); |
|
| 70 | + $key=$this->getCacheKey(array(clone($sql), $parameter, $skip, $max)); |
|
| 71 | + $list=$this->getStatement()->getCache()->get($key); |
|
| 72 | 72 | if($list===null) |
| 73 | 73 | { |
| 74 | - $list = $this->_mappedStatement->runQueryForList( |
|
| 74 | + $list=$this->_mappedStatement->runQueryForList( |
|
| 75 | 75 | $connection, $parameter, $sql, $result, $delegate); |
| 76 | 76 | $this->getStatement()->getCache()->set($key, $list); |
| 77 | 77 | } |
@@ -80,12 +80,12 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | public function executeQueryForObject($connection, $parameter, $result=null) |
| 82 | 82 | { |
| 83 | - $sql = $this->createCommand($connection, $parameter); |
|
| 84 | - $key = $this->getCacheKey(array(clone($sql), $parameter)); |
|
| 85 | - $object = $this->getStatement()->getCache()->get($key); |
|
| 83 | + $sql=$this->createCommand($connection, $parameter); |
|
| 84 | + $key=$this->getCacheKey(array(clone($sql), $parameter)); |
|
| 85 | + $object=$this->getStatement()->getCache()->get($key); |
|
| 86 | 86 | if($object===null) |
| 87 | 87 | { |
| 88 | - $object = $this->_mappedStatement->runQueryForObject($connection, $sql, $result); |
|
| 88 | + $object=$this->_mappedStatement->runQueryForObject($connection, $sql, $result); |
|
| 89 | 89 | $this->getStatement()->getCache()->set($key, $object); |
| 90 | 90 | } |
| 91 | 91 | return $object; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | protected function getCacheKey($object) |
| 95 | 95 | { |
| 96 | - $cacheKey = new TSqlMapCacheKey($object); |
|
| 96 | + $cacheKey=new TSqlMapCacheKey($object); |
|
| 97 | 97 | return $cacheKey->getHash(); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | - * @return TSqlMapper The SqlMap used by this MappedStatement |
|
| 87 | + * @return TSqlMapManager The SqlMap used by this MappedStatement |
|
| 88 | 88 | */ |
| 89 | 89 | public function getManager() |
| 90 | 90 | { |
@@ -469,6 +469,7 @@ discard block |
||
| 469 | 469 | * @param IDbConnection database connection |
| 470 | 470 | * @param mixed insert statement parameter |
| 471 | 471 | * @param TSqlMapSelectKey select key statement |
| 472 | + * @param TSqlMapSelectKey $selectKey |
|
| 472 | 473 | * @return string last insert ID. |
| 473 | 474 | */ |
| 474 | 475 | protected function executeSelectKey($connection, $parameter, $selectKey) |
@@ -569,6 +570,7 @@ discard block |
||
| 569 | 570 | * @param string result object class name |
| 570 | 571 | * @param array a result set row retrieved from the database |
| 571 | 572 | * @param object the result object, will create if necessary. |
| 573 | + * @param string $resultClass |
|
| 572 | 574 | * @return object result object filled with data |
| 573 | 575 | */ |
| 574 | 576 | protected function fillResultClass($resultClass, $row, $resultObject) |
@@ -591,6 +593,7 @@ discard block |
||
| 591 | 593 | * Apply the result to a TList or an array. |
| 592 | 594 | * @param array a result set row retrieved from the database |
| 593 | 595 | * @param object result object, array or list |
| 596 | + * @param ArrayAccess $resultObject |
|
| 594 | 597 | * @return object result filled with data. |
| 595 | 598 | */ |
| 596 | 599 | protected function fillResultArrayList($row, $resultObject) |
@@ -633,6 +636,7 @@ discard block |
||
| 633 | 636 | * @param string result map name. |
| 634 | 637 | * @param array a result set row retrieved from the database |
| 635 | 638 | * @param object result object to fill, will create new instances if required. |
| 639 | + * @param string $parentGroup |
|
| 636 | 640 | * @return object result object filled with data. |
| 637 | 641 | */ |
| 638 | 642 | protected function fillResultMap($resultMapName, $row, $parentGroup=null, &$resultObject=null) |
@@ -772,6 +776,7 @@ discard block |
||
| 772 | 776 | * Converts the first array value to scalar value of given type. |
| 773 | 777 | * @param array list of results |
| 774 | 778 | * @param string scalar type. |
| 779 | + * @param string $type |
|
| 775 | 780 | * @return mixed scalar value. |
| 776 | 781 | */ |
| 777 | 782 | protected function getScalarResult($result, $type) |
@@ -961,6 +966,10 @@ discard block |
||
| 961 | 966 | public function setKeys($value){ $this->_keys = $value; } |
| 962 | 967 | |
| 963 | 968 | public function getMethod(){ return $this->_method; } |
| 969 | + |
|
| 970 | + /** |
|
| 971 | + * @param integer $value |
|
| 972 | + */ |
|
| 964 | 973 | public function setMethod($value){ $this->_method = $value; } |
| 965 | 974 | } |
| 966 | 975 | |
@@ -1003,6 +1012,7 @@ discard block |
||
| 1003 | 1012 | * @param string parent node id |
| 1004 | 1013 | * @param string new node id |
| 1005 | 1014 | * @param mixed node value |
| 1015 | + * @param string $node |
|
| 1006 | 1016 | */ |
| 1007 | 1017 | public function add($parent, $node, $object='') |
| 1008 | 1018 | { |
@@ -1168,6 +1178,9 @@ discard block |
||
| 1168 | 1178 | private $_parameterObject; |
| 1169 | 1179 | private $_list; |
| 1170 | 1180 | |
| 1181 | + /** |
|
| 1182 | + * @param ArrayAccess $list |
|
| 1183 | + */ |
|
| 1171 | 1184 | public function __construct($result, $parameter, &$list) |
| 1172 | 1185 | { |
| 1173 | 1186 | $this->_resultObject = $result; |
@@ -237,8 +237,7 @@ discard block |
||
| 237 | 237 | $param = new TResultSetListItemParameter($obj, $parameter, $list); |
| 238 | 238 | $this->raiseRowDelegate($delegate, $param); |
| 239 | 239 | } |
| 240 | - } |
|
| 241 | - else |
|
| 240 | + } else |
|
| 242 | 241 | { |
| 243 | 242 | //var_dump($sql,$parameter); |
| 244 | 243 | foreach($reader as $row) |
@@ -314,8 +313,7 @@ discard block |
||
| 314 | 313 | $param = new TResultSetMapItemParameter($key, $value, $parameter, $map); |
| 315 | 314 | $this->raiseRowDelegate($delegate, $param); |
| 316 | 315 | } |
| 317 | - } |
|
| 318 | - else |
|
| 316 | + } else |
|
| 319 | 317 | { |
| 320 | 318 | //while($row = $recordSet->fetchRow()) |
| 321 | 319 | foreach($reader as $row) |
@@ -341,8 +339,7 @@ discard block |
||
| 341 | 339 | if(is_string($handler)) |
| 342 | 340 | { |
| 343 | 341 | call_user_func($handler,$this,$param); |
| 344 | - } |
|
| 345 | - else if(is_callable($handler,true)) |
|
| 342 | + } else if(is_callable($handler,true)) |
|
| 346 | 343 | { |
| 347 | 344 | // an array: 0 - object, 1 - method name/path |
| 348 | 345 | list($object,$method)=$handler; |
@@ -357,8 +354,7 @@ discard block |
||
| 357 | 354 | } |
| 358 | 355 | $object->$method($this,$param); |
| 359 | 356 | } |
| 360 | - } |
|
| 361 | - else |
|
| 357 | + } else |
|
| 362 | 358 | throw new TInvalidDataValueException('sqlmap_invalid_delegate', $this->getID(), $handler); |
| 363 | 359 | } |
| 364 | 360 | |
@@ -520,8 +516,7 @@ discard block |
||
| 520 | 516 | if($method == self::QUERY_FOR_ARRAY) |
| 521 | 517 | $values = $values->toArray(); |
| 522 | 518 | TPropertyAccess::set($resultObject, $property, $values); |
| 523 | - } |
|
| 524 | - else if($method == self::QUERY_FOR_OBJECT) |
|
| 519 | + } else if($method == self::QUERY_FOR_OBJECT) |
|
| 525 | 520 | { |
| 526 | 521 | $value = $statement->executeQueryForObject($connection, $keys, null); |
| 527 | 522 | TPropertyAccess::set($resultObject, $property, $value); |
@@ -651,8 +646,7 @@ discard block |
||
| 651 | 646 | else |
| 652 | 647 | foreach($resultMap->getColumns() as $property) |
| 653 | 648 | $this->setObjectProperty($resultMap, $property, $row, $resultObject); |
| 654 | - } |
|
| 655 | - else |
|
| 649 | + } else |
|
| 656 | 650 | { |
| 657 | 651 | $resultObject = $this->fillDefaultResultMap($resultMap, $row, $resultObject); |
| 658 | 652 | } |
@@ -797,8 +791,7 @@ discard block |
||
| 797 | 791 | if($key === '') |
| 798 | 792 | { |
| 799 | 793 | $resultObject = $property->getPropertyValue($registry,$row); |
| 800 | - } |
|
| 801 | - else if(strlen($select) == 0 && ($nested===null)) |
|
| 794 | + } else if(strlen($select) == 0 && ($nested===null)) |
|
| 802 | 795 | { |
| 803 | 796 | $value = $property->getPropertyValue($registry,$row); |
| 804 | 797 | |
@@ -807,8 +800,7 @@ discard block |
||
| 807 | 800 | TPropertyAccess::set($resultObject, $key, $value); |
| 808 | 801 | else |
| 809 | 802 | $resultObject = $value; |
| 810 | - } |
|
| 811 | - else if($nested!==null) |
|
| 803 | + } else if($nested!==null) |
|
| 812 | 804 | { |
| 813 | 805 | if($property->instanceOfListType($resultObject) || $property->instanceOfArrayType($resultObject)) |
| 814 | 806 | { |
@@ -816,16 +808,14 @@ discard block |
||
| 816 | 808 | throw new TSqlMapExecutionException( |
| 817 | 809 | 'sqlmap_non_groupby_array_list_type', $resultMap->getID(), |
| 818 | 810 | get_class($resultObject), $key); |
| 819 | - } |
|
| 820 | - else |
|
| 811 | + } else |
|
| 821 | 812 | { |
| 822 | 813 | $obj = $nested->createInstanceOfResult($this->getManager()->getTypeHandlers()); |
| 823 | 814 | if($this->fillPropertyWithResultMap($nested, $row, $obj) == false) |
| 824 | 815 | $obj = null; |
| 825 | 816 | TPropertyAccess::set($resultObject, $key, $obj); |
| 826 | 817 | } |
| 827 | - } |
|
| 828 | - else //'select' ResultProperty |
|
| 818 | + } else //'select' ResultProperty |
|
| 829 | 819 | { |
| 830 | 820 | $this->enquequePostSelect($select, $resultMap, $property, $row, $resultObject); |
| 831 | 821 | } |
@@ -857,11 +847,9 @@ discard block |
||
| 857 | 847 | $values = TLazyLoadList::newInstance($statement, $key, |
| 858 | 848 | $resultObject, $property->getProperty()); |
| 859 | 849 | TPropertyAccess::set($resultObject, $property->getProperty(), $values); |
| 860 | - } |
|
| 861 | - else |
|
| 850 | + } else |
|
| 862 | 851 | $postSelect->setMethod(self::QUERY_FOR_LIST); |
| 863 | - } |
|
| 864 | - else if($property->instanceOfArrayType($resultObject)) |
|
| 852 | + } else if($property->instanceOfArrayType($resultObject)) |
|
| 865 | 853 | $postSelect->setMethod(self::QUERY_FOR_ARRAY); |
| 866 | 854 | else |
| 867 | 855 | $postSelect->setMethod(self::QUERY_FOR_OBJECT); |
@@ -889,8 +877,7 @@ discard block |
||
| 889 | 877 | $keys[trim($pair[0])] = $row[trim($pair[1])]; |
| 890 | 878 | } |
| 891 | 879 | return $keys; |
| 892 | - } |
|
| 893 | - else |
|
| 880 | + } else |
|
| 894 | 881 | { |
| 895 | 882 | $registry=$this->getManager()->getTypeHandlers(); |
| 896 | 883 | return $property->getPropertyValue($registry,$row); |
@@ -1048,8 +1035,7 @@ discard block |
||
| 1048 | 1035 | { |
| 1049 | 1036 | $found = true; |
| 1050 | 1037 | $childs[$key][$node] = array(); |
| 1051 | - } |
|
| 1052 | - else |
|
| 1038 | + } else |
|
| 1053 | 1039 | { |
| 1054 | 1040 | $found = $found || $this->addNode($childs[$key], $parent, $node); |
| 1055 | 1041 | } |
@@ -1062,8 +1048,9 @@ discard block |
||
| 1062 | 1048 | */ |
| 1063 | 1049 | public function collect() |
| 1064 | 1050 | { |
| 1065 | - while(count($this->_tree) > 0) |
|
| 1066 | - $this->collectChildren(null, $this->_tree); |
|
| 1051 | + while(count($this->_tree) > 0) { |
|
| 1052 | + $this->collectChildren(null, $this->_tree); |
|
| 1053 | + } |
|
| 1067 | 1054 | return $this->getCollection(); |
| 1068 | 1055 | } |
| 1069 | 1056 | |
@@ -1096,8 +1083,7 @@ discard block |
||
| 1096 | 1083 | { |
| 1097 | 1084 | $childs[] = $key; |
| 1098 | 1085 | unset($nodes[$key]); |
| 1099 | - } |
|
| 1100 | - else |
|
| 1086 | + } else |
|
| 1101 | 1087 | $this->collectChildren($key, $nodes[$key]); |
| 1102 | 1088 | } |
| 1103 | 1089 | if(count($childs) > 0) |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | /** |
| 45 | 45 | * @var boolean true when data is mapped to a particular row. |
| 46 | 46 | */ |
| 47 | - private $_IsRowDataFound = false; |
|
| 47 | + private $_IsRowDataFound=false; |
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @var TSQLMapObjectCollectionTree group by object collection tree |
@@ -54,17 +54,17 @@ discard block |
||
| 54 | 54 | /** |
| 55 | 55 | * @var Post select is to query for list. |
| 56 | 56 | */ |
| 57 | - const QUERY_FOR_LIST = 0; |
|
| 57 | + const QUERY_FOR_LIST=0; |
|
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * @var Post select is to query for list. |
| 61 | 61 | */ |
| 62 | - const QUERY_FOR_ARRAY = 1; |
|
| 62 | + const QUERY_FOR_ARRAY=1; |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * @var Post select is to query for object. |
| 66 | 66 | */ |
| 67 | - const QUERY_FOR_OBJECT = 2; |
|
| 67 | + const QUERY_FOR_OBJECT=2; |
|
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * @return string Name used to identify the TMappedStatement amongst the others. |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | protected function initialGroupByResults() |
| 106 | 106 | { |
| 107 | - $this->_groupBy = new TSqlMapObjectCollectionTree(); |
|
| 107 | + $this->_groupBy=new TSqlMapObjectCollectionTree(); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public function __construct(TSqlMapManager $sqlMap, TSqlMapStatement $statement) |
| 116 | 116 | { |
| 117 | - $this->_manager = $sqlMap; |
|
| 118 | - $this->_statement = $statement; |
|
| 119 | - $this->_command = new TPreparedCommand(); |
|
| 117 | + $this->_manager=$sqlMap; |
|
| 118 | + $this->_statement=$statement; |
|
| 119 | + $this->_command=new TPreparedCommand(); |
|
| 120 | 120 | $this->initialGroupByResults(); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -161,10 +161,10 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | protected function executeSQLQueryLimit($connection, $command, $max, $skip) |
| 163 | 163 | { |
| 164 | - if($max>-1 || $skip > -1) |
|
| 164 | + if($max > -1 || $skip > -1) |
|
| 165 | 165 | { |
| 166 | - $maxStr=$max>0?' LIMIT '.$max:''; |
|
| 167 | - $skipStr=$skip>0?' OFFSET '.$skip:''; |
|
| 166 | + $maxStr=$max > 0 ? ' LIMIT '.$max : ''; |
|
| 167 | + $skipStr=$skip > 0 ? ' OFFSET '.$skip : ''; |
|
| 168 | 168 | $command->setText($command->getText().$maxStr.$skipStr); |
| 169 | 169 | } |
| 170 | 170 | $connection->setActive(true); |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | public function executeQueryForList($connection, $parameter, $result=null, $skip=-1, $max=-1, $delegate=null) |
| 203 | 203 | { |
| 204 | - $sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter,$skip,$max); |
|
| 204 | + $sql=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter, $skip, $max); |
|
| 205 | 205 | return $this->runQueryForList($connection, $parameter, $sql, $result, $delegate); |
| 206 | 206 | } |
| 207 | 207 | |
@@ -224,17 +224,16 @@ discard block |
||
| 224 | 224 | public function runQueryForList($connection, $parameter, $sql, $result, $delegate=null) |
| 225 | 225 | { |
| 226 | 226 | $registry=$this->getManager()->getTypeHandlers(); |
| 227 | - $list = $result instanceof ArrayAccess ? $result : |
|
| 228 | - $this->_statement->createInstanceOfListClass($registry); |
|
| 227 | + $list=$result instanceof ArrayAccess ? $result : $this->_statement->createInstanceOfListClass($registry); |
|
| 229 | 228 | $connection->setActive(true); |
| 230 | - $reader = $sql->query(); |
|
| 229 | + $reader=$sql->query(); |
|
| 231 | 230 | //$reader = $this->executeSQLQueryLimit($connection, $sql, $max, $skip); |
| 232 | 231 | if($delegate!==null) |
| 233 | 232 | { |
| 234 | 233 | foreach($reader as $row) |
| 235 | 234 | { |
| 236 | - $obj = $this->applyResultMap($row); |
|
| 237 | - $param = new TResultSetListItemParameter($obj, $parameter, $list); |
|
| 235 | + $obj=$this->applyResultMap($row); |
|
| 236 | + $param=new TResultSetListItemParameter($obj, $parameter, $list); |
|
| 238 | 237 | $this->raiseRowDelegate($delegate, $param); |
| 239 | 238 | } |
| 240 | 239 | } |
@@ -244,13 +243,13 @@ discard block |
||
| 244 | 243 | foreach($reader as $row) |
| 245 | 244 | { |
| 246 | 245 | // var_dump($row); |
| 247 | - $list[] = $this->applyResultMap($row); |
|
| 246 | + $list[]=$this->applyResultMap($row); |
|
| 248 | 247 | } |
| 249 | 248 | } |
| 250 | 249 | |
| 251 | 250 | if(!$this->_groupBy->isEmpty()) |
| 252 | 251 | { |
| 253 | - $list = $this->_groupBy->collect(); |
|
| 252 | + $list=$this->_groupBy->collect(); |
|
| 254 | 253 | $this->initialGroupByResults(); |
| 255 | 254 | } |
| 256 | 255 | |
@@ -272,9 +271,9 @@ discard block |
||
| 272 | 271 | * @param callback row delegate handler |
| 273 | 272 | * @return array An array of object containing the rows keyed by keyProperty. |
| 274 | 273 | */ |
| 275 | - public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty=null, $skip=-1, $max=-1, $delegate=null) |
|
| 274 | + public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty=null, $skip=-1, $max=-1, $delegate=null) |
|
| 276 | 275 | { |
| 277 | - $sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter, $skip, $max); |
|
| 276 | + $sql=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter, $skip, $max); |
|
| 278 | 277 | return $this->runQueryForMap($connection, $parameter, $sql, $keyProperty, $valueProperty, $delegate); |
| 279 | 278 | } |
| 280 | 279 | |
@@ -298,20 +297,19 @@ discard block |
||
| 298 | 297 | */ |
| 299 | 298 | public function runQueryForMap($connection, $parameter, $command, $keyProperty, $valueProperty=null, $delegate=null) |
| 300 | 299 | { |
| 301 | - $map = array(); |
|
| 300 | + $map=array(); |
|
| 302 | 301 | //$recordSet = $this->executeSQLQuery($connection, $sql); |
| 303 | 302 | $connection->setActive(true); |
| 304 | - $reader = $command->query(); |
|
| 303 | + $reader=$command->query(); |
|
| 305 | 304 | if($delegate!==null) |
| 306 | 305 | { |
| 307 | 306 | //while($row = $recordSet->fetchRow()) |
| 308 | 307 | foreach($reader as $row) |
| 309 | 308 | { |
| 310 | - $obj = $this->applyResultMap($row); |
|
| 311 | - $key = TPropertyAccess::get($obj, $keyProperty); |
|
| 312 | - $value = ($valueProperty===null) ? $obj : |
|
| 313 | - TPropertyAccess::get($obj, $valueProperty); |
|
| 314 | - $param = new TResultSetMapItemParameter($key, $value, $parameter, $map); |
|
| 309 | + $obj=$this->applyResultMap($row); |
|
| 310 | + $key=TPropertyAccess::get($obj, $keyProperty); |
|
| 311 | + $value=($valueProperty===null) ? $obj : TPropertyAccess::get($obj, $valueProperty); |
|
| 312 | + $param=new TResultSetMapItemParameter($key, $value, $parameter, $map); |
|
| 315 | 313 | $this->raiseRowDelegate($delegate, $param); |
| 316 | 314 | } |
| 317 | 315 | } |
@@ -320,10 +318,9 @@ discard block |
||
| 320 | 318 | //while($row = $recordSet->fetchRow()) |
| 321 | 319 | foreach($reader as $row) |
| 322 | 320 | { |
| 323 | - $obj = $this->applyResultMap($row); |
|
| 324 | - $key = TPropertyAccess::get($obj, $keyProperty); |
|
| 325 | - $map[$key] = ($valueProperty===null) ? $obj : |
|
| 326 | - TPropertyAccess::get($obj, $valueProperty); |
|
| 321 | + $obj=$this->applyResultMap($row); |
|
| 322 | + $key=TPropertyAccess::get($obj, $keyProperty); |
|
| 323 | + $map[$key]=($valueProperty===null) ? $obj : TPropertyAccess::get($obj, $valueProperty); |
|
| 327 | 324 | } |
| 328 | 325 | } |
| 329 | 326 | $this->onExecuteQuery($command); |
@@ -340,22 +337,22 @@ discard block |
||
| 340 | 337 | { |
| 341 | 338 | if(is_string($handler)) |
| 342 | 339 | { |
| 343 | - call_user_func($handler,$this,$param); |
|
| 340 | + call_user_func($handler, $this, $param); |
|
| 344 | 341 | } |
| 345 | - else if(is_callable($handler,true)) |
|
| 342 | + else if(is_callable($handler, true)) |
|
| 346 | 343 | { |
| 347 | 344 | // an array: 0 - object, 1 - method name/path |
| 348 | - list($object,$method)=$handler; |
|
| 345 | + list($object, $method)=$handler; |
|
| 349 | 346 | if(is_string($object)) // static method call |
| 350 | - call_user_func($handler,$this,$param); |
|
| 347 | + call_user_func($handler, $this, $param); |
|
| 351 | 348 | else |
| 352 | 349 | { |
| 353 | - if(($pos=strrpos($method,'.'))!==false) |
|
| 350 | + if(($pos=strrpos($method, '.'))!==false) |
|
| 354 | 351 | { |
| 355 | - $object=$this->getSubProperty(substr($method,0,$pos)); |
|
| 356 | - $method=substr($method,$pos+1); |
|
| 352 | + $object=$this->getSubProperty(substr($method, 0, $pos)); |
|
| 353 | + $method=substr($method, $pos + 1); |
|
| 357 | 354 | } |
| 358 | - $object->$method($this,$param); |
|
| 355 | + $object->$method($this, $param); |
|
| 359 | 356 | } |
| 360 | 357 | } |
| 361 | 358 | else |
@@ -372,7 +369,7 @@ discard block |
||
| 372 | 369 | */ |
| 373 | 370 | public function executeQueryForObject($connection, $parameter, $result=null) |
| 374 | 371 | { |
| 375 | - $sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
| 372 | + $sql=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
| 376 | 373 | return $this->runQueryForObject($connection, $sql, $result); |
| 377 | 374 | } |
| 378 | 375 | |
@@ -391,16 +388,16 @@ discard block |
||
| 391 | 388 | */ |
| 392 | 389 | public function runQueryForObject($connection, $command, &$result) |
| 393 | 390 | { |
| 394 | - $object = null; |
|
| 391 | + $object=null; |
|
| 395 | 392 | $connection->setActive(true); |
| 396 | 393 | foreach($command->query() as $row) |
| 397 | - $object = $this->applyResultMap($row, $result); |
|
| 394 | + $object=$this->applyResultMap($row, $result); |
|
| 398 | 395 | |
| 399 | 396 | if(!$this->_groupBy->isEmpty()) |
| 400 | 397 | { |
| 401 | - $list = $this->_groupBy->collect(); |
|
| 398 | + $list=$this->_groupBy->collect(); |
|
| 402 | 399 | $this->initialGroupByResults(); |
| 403 | - $object = $list[0]; |
|
| 400 | + $object=$list[0]; |
|
| 404 | 401 | } |
| 405 | 402 | |
| 406 | 403 | $this->executePostSelect($connection); |
@@ -418,14 +415,14 @@ discard block |
||
| 418 | 415 | */ |
| 419 | 416 | public function executeInsert($connection, $parameter) |
| 420 | 417 | { |
| 421 | - $generatedKey = $this->getPreGeneratedSelectKey($connection, $parameter); |
|
| 418 | + $generatedKey=$this->getPreGeneratedSelectKey($connection, $parameter); |
|
| 422 | 419 | |
| 423 | - $command = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
| 420 | + $command=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
| 424 | 421 | // var_dump($command,$parameter); |
| 425 | - $result = $command->execute(); |
|
| 422 | + $result=$command->execute(); |
|
| 426 | 423 | |
| 427 | 424 | if($generatedKey===null) |
| 428 | - $generatedKey = $this->getPostGeneratedSelectKey($connection, $parameter); |
|
| 425 | + $generatedKey=$this->getPostGeneratedSelectKey($connection, $parameter); |
|
| 429 | 426 | |
| 430 | 427 | $this->executePostSelect($connection); |
| 431 | 428 | $this->onExecuteQuery($command); |
@@ -442,7 +439,7 @@ discard block |
||
| 442 | 439 | { |
| 443 | 440 | if($this->_statement instanceof TSqlMapInsert) |
| 444 | 441 | { |
| 445 | - $selectKey = $this->_statement->getSelectKey(); |
|
| 442 | + $selectKey=$this->_statement->getSelectKey(); |
|
| 446 | 443 | if(($selectKey!==null) && !$selectKey->getIsAfter()) |
| 447 | 444 | return $this->executeSelectKey($connection, $parameter, $selectKey); |
| 448 | 445 | } |
@@ -458,7 +455,7 @@ discard block |
||
| 458 | 455 | { |
| 459 | 456 | if($this->_statement instanceof TSqlMapInsert) |
| 460 | 457 | { |
| 461 | - $selectKey = $this->_statement->getSelectKey(); |
|
| 458 | + $selectKey=$this->_statement->getSelectKey(); |
|
| 462 | 459 | if(($selectKey!==null) && $selectKey->getIsAfter()) |
| 463 | 460 | return $this->executeSelectKey($connection, $parameter, $selectKey); |
| 464 | 461 | } |
@@ -473,10 +470,10 @@ discard block |
||
| 473 | 470 | */ |
| 474 | 471 | protected function executeSelectKey($connection, $parameter, $selectKey) |
| 475 | 472 | { |
| 476 | - $mappedStatement = $this->getManager()->getMappedStatement($selectKey->getID()); |
|
| 477 | - $generatedKey = $mappedStatement->executeQueryForObject( |
|
| 473 | + $mappedStatement=$this->getManager()->getMappedStatement($selectKey->getID()); |
|
| 474 | + $generatedKey=$mappedStatement->executeQueryForObject( |
|
| 478 | 475 | $connection, $parameter, null); |
| 479 | - if(strlen($prop = $selectKey->getProperty()) > 0) |
|
| 476 | + if(strlen($prop=$selectKey->getProperty()) > 0) |
|
| 480 | 477 | TPropertyAccess::set($parameter, $prop, $generatedKey); |
| 481 | 478 | return $generatedKey; |
| 482 | 479 | } |
@@ -490,8 +487,8 @@ discard block |
||
| 490 | 487 | */ |
| 491 | 488 | public function executeUpdate($connection, $parameter) |
| 492 | 489 | { |
| 493 | - $sql = $this->_command->create($this->getManager(),$connection, $this->_statement, $parameter); |
|
| 494 | - $affectedRows = $sql->execute(); |
|
| 490 | + $sql=$this->_command->create($this->getManager(), $connection, $this->_statement, $parameter); |
|
| 491 | + $affectedRows=$sql->execute(); |
|
| 495 | 492 | //$this->executeSQLQuery($connection, $sql); |
| 496 | 493 | $this->executePostSelect($connection); |
| 497 | 494 | $this->onExecuteQuery($sql); |
@@ -506,24 +503,24 @@ discard block |
||
| 506 | 503 | { |
| 507 | 504 | while(count($this->_selectQueue)) |
| 508 | 505 | { |
| 509 | - $postSelect = array_shift($this->_selectQueue); |
|
| 510 | - $method = $postSelect->getMethod(); |
|
| 511 | - $statement = $postSelect->getStatement(); |
|
| 512 | - $property = $postSelect->getResultProperty()->getProperty(); |
|
| 513 | - $keys = $postSelect->getKeys(); |
|
| 514 | - $resultObject = $postSelect->getResultObject(); |
|
| 515 | - |
|
| 516 | - if($method == self::QUERY_FOR_LIST || $method == self::QUERY_FOR_ARRAY) |
|
| 506 | + $postSelect=array_shift($this->_selectQueue); |
|
| 507 | + $method=$postSelect->getMethod(); |
|
| 508 | + $statement=$postSelect->getStatement(); |
|
| 509 | + $property=$postSelect->getResultProperty()->getProperty(); |
|
| 510 | + $keys=$postSelect->getKeys(); |
|
| 511 | + $resultObject=$postSelect->getResultObject(); |
|
| 512 | + |
|
| 513 | + if($method==self::QUERY_FOR_LIST || $method==self::QUERY_FOR_ARRAY) |
|
| 517 | 514 | { |
| 518 | - $values = $statement->executeQueryForList($connection, $keys, null); |
|
| 515 | + $values=$statement->executeQueryForList($connection, $keys, null); |
|
| 519 | 516 | |
| 520 | - if($method == self::QUERY_FOR_ARRAY) |
|
| 521 | - $values = $values->toArray(); |
|
| 517 | + if($method==self::QUERY_FOR_ARRAY) |
|
| 518 | + $values=$values->toArray(); |
|
| 522 | 519 | TPropertyAccess::set($resultObject, $property, $values); |
| 523 | 520 | } |
| 524 | - else if($method == self::QUERY_FOR_OBJECT) |
|
| 521 | + else if($method==self::QUERY_FOR_OBJECT) |
|
| 525 | 522 | { |
| 526 | - $value = $statement->executeQueryForObject($connection, $keys, null); |
|
| 523 | + $value=$statement->executeQueryForObject($connection, $keys, null); |
|
| 527 | 524 | TPropertyAccess::set($resultObject, $property, $value); |
| 528 | 525 | } |
| 529 | 526 | } |
@@ -546,21 +543,21 @@ discard block |
||
| 546 | 543 | */ |
| 547 | 544 | protected function applyResultMap($row, &$resultObject=null) |
| 548 | 545 | { |
| 549 | - if($row === false) return null; |
|
| 546 | + if($row===false) return null; |
|
| 550 | 547 | |
| 551 | - $resultMapName = $this->_statement->getResultMap(); |
|
| 552 | - $resultClass = $this->_statement->getResultClass(); |
|
| 548 | + $resultMapName=$this->_statement->getResultMap(); |
|
| 549 | + $resultClass=$this->_statement->getResultClass(); |
|
| 553 | 550 | |
| 554 | 551 | $obj=null; |
| 555 | 552 | if($this->getManager()->getResultMaps()->contains($resultMapName)) |
| 556 | - $obj = $this->fillResultMap($resultMapName, $row, null, $resultObject); |
|
| 553 | + $obj=$this->fillResultMap($resultMapName, $row, null, $resultObject); |
|
| 557 | 554 | else if(strlen($resultClass) > 0) |
| 558 | - $obj = $this->fillResultClass($resultClass, $row, $resultObject); |
|
| 555 | + $obj=$this->fillResultClass($resultClass, $row, $resultObject); |
|
| 559 | 556 | else |
| 560 | - $obj = $this->fillDefaultResultMap(null, $row, $resultObject); |
|
| 561 | - if(class_exists('TActiveRecord',false) && $obj instanceof TActiveRecord) |
|
| 557 | + $obj=$this->fillDefaultResultMap(null, $row, $resultObject); |
|
| 558 | + if(class_exists('TActiveRecord', false) && $obj instanceof TActiveRecord) |
|
| 562 | 559 | //Create a new clean active record. |
| 563 | - $obj=TActiveRecord::createRecord(get_class($obj),$obj); |
|
| 560 | + $obj=TActiveRecord::createRecord(get_class($obj), $obj); |
|
| 564 | 561 | return $obj; |
| 565 | 562 | } |
| 566 | 563 | |
@@ -575,8 +572,8 @@ discard block |
||
| 575 | 572 | { |
| 576 | 573 | if($resultObject===null) |
| 577 | 574 | { |
| 578 | - $registry = $this->getManager()->getTypeHandlers(); |
|
| 579 | - $resultObject = $this->_statement->createInstanceOfResultClass($registry,$row); |
|
| 575 | + $registry=$this->getManager()->getTypeHandlers(); |
|
| 576 | + $resultObject=$this->_statement->createInstanceOfResultClass($registry, $row); |
|
| 580 | 577 | } |
| 581 | 578 | |
| 582 | 579 | if($resultObject instanceOf ArrayAccess) |
@@ -597,10 +594,10 @@ discard block |
||
| 597 | 594 | { |
| 598 | 595 | if($resultObject instanceof TList) |
| 599 | 596 | foreach($row as $v) |
| 600 | - $resultObject[] = $v; |
|
| 597 | + $resultObject[]=$v; |
|
| 601 | 598 | else |
| 602 | 599 | foreach($row as $k => $v) |
| 603 | - $resultObject[$k] = $v; |
|
| 600 | + $resultObject[$k]=$v; |
|
| 604 | 601 | return $resultObject; |
| 605 | 602 | } |
| 606 | 603 | |
@@ -612,18 +609,18 @@ discard block |
||
| 612 | 609 | */ |
| 613 | 610 | protected function fillResultObjectProperty($row, $resultObject) |
| 614 | 611 | { |
| 615 | - $index = 0; |
|
| 612 | + $index=0; |
|
| 616 | 613 | $registry=$this->getManager()->getTypeHandlers(); |
| 617 | 614 | foreach($row as $k=>$v) |
| 618 | 615 | { |
| 619 | - $property = new TResultProperty; |
|
| 616 | + $property=new TResultProperty; |
|
| 620 | 617 | if(is_string($k) && strlen($k) > 0) |
| 621 | 618 | $property->setColumn($k); |
| 622 | 619 | $property->setColumnIndex(++$index); |
| 623 | - $type = gettype(TPropertyAccess::get($resultObject,$k)); |
|
| 620 | + $type=gettype(TPropertyAccess::get($resultObject, $k)); |
|
| 624 | 621 | $property->setType($type); |
| 625 | - $value = $property->getPropertyValue($registry,$row); |
|
| 626 | - TPropertyAccess::set($resultObject, $k,$value); |
|
| 622 | + $value=$property->getPropertyValue($registry, $row); |
|
| 623 | + TPropertyAccess::set($resultObject, $k, $value); |
|
| 627 | 624 | } |
| 628 | 625 | return $resultObject; |
| 629 | 626 | } |
@@ -637,12 +634,12 @@ discard block |
||
| 637 | 634 | */ |
| 638 | 635 | protected function fillResultMap($resultMapName, $row, $parentGroup=null, &$resultObject=null) |
| 639 | 636 | { |
| 640 | - $resultMap = $this->getManager()->getResultMap($resultMapName); |
|
| 641 | - $registry = $this->getManager()->getTypeHandlers(); |
|
| 642 | - $resultMap = $resultMap->resolveSubMap($registry,$row); |
|
| 637 | + $resultMap=$this->getManager()->getResultMap($resultMapName); |
|
| 638 | + $registry=$this->getManager()->getTypeHandlers(); |
|
| 639 | + $resultMap=$resultMap->resolveSubMap($registry, $row); |
|
| 643 | 640 | |
| 644 | 641 | if($resultObject===null) |
| 645 | - $resultObject = $resultMap->createInstanceOfResult($registry); |
|
| 642 | + $resultObject=$resultMap->createInstanceOfResult($registry); |
|
| 646 | 643 | |
| 647 | 644 | if(is_object($resultObject)) |
| 648 | 645 | { |
@@ -654,7 +651,7 @@ discard block |
||
| 654 | 651 | } |
| 655 | 652 | else |
| 656 | 653 | { |
| 657 | - $resultObject = $this->fillDefaultResultMap($resultMap, $row, $resultObject); |
|
| 654 | + $resultObject=$this->fillDefaultResultMap($resultMap, $row, $resultObject); |
|
| 658 | 655 | } |
| 659 | 656 | return $resultObject; |
| 660 | 657 | } |
@@ -669,11 +666,11 @@ discard block |
||
| 669 | 666 | */ |
| 670 | 667 | protected function addResultMapGroupBy($resultMap, $row, $parent, &$resultObject) |
| 671 | 668 | { |
| 672 | - $group = $this->getResultMapGroupKey($resultMap, $row); |
|
| 669 | + $group=$this->getResultMapGroupKey($resultMap, $row); |
|
| 673 | 670 | |
| 674 | 671 | if(empty($parent)) |
| 675 | 672 | { |
| 676 | - $rootObject = array('object'=>$resultObject, 'property' => null); |
|
| 673 | + $rootObject=array('object'=>$resultObject, 'property' => null); |
|
| 677 | 674 | $this->_groupBy->add(null, $group, $rootObject); |
| 678 | 675 | } |
| 679 | 676 | |
@@ -681,23 +678,23 @@ discard block |
||
| 681 | 678 | { |
| 682 | 679 | //set properties. |
| 683 | 680 | $this->setObjectProperty($resultMap, $property, $row, $resultObject); |
| 684 | - $nested = $property->getResultMapping(); |
|
| 681 | + $nested=$property->getResultMapping(); |
|
| 685 | 682 | |
| 686 | 683 | //nested property |
| 687 | 684 | if($this->getManager()->getResultMaps()->contains($nested)) |
| 688 | 685 | { |
| 689 | - $nestedMap = $this->getManager()->getResultMap($nested); |
|
| 690 | - $groupKey = $this->getResultMapGroupKey($nestedMap, $row); |
|
| 686 | + $nestedMap=$this->getManager()->getResultMap($nested); |
|
| 687 | + $groupKey=$this->getResultMapGroupKey($nestedMap, $row); |
|
| 691 | 688 | |
| 692 | 689 | //add the node reference first |
| 693 | 690 | if(empty($parent)) |
| 694 | 691 | $this->_groupBy->add($group, $groupKey, ''); |
| 695 | 692 | |
| 696 | 693 | //get the nested result mapping value |
| 697 | - $value = $this->fillResultMap($nested, $row, $groupKey); |
|
| 694 | + $value=$this->fillResultMap($nested, $row, $groupKey); |
|
| 698 | 695 | |
| 699 | 696 | //add it to the object tree graph |
| 700 | - $groupObject = array('object'=>$value, 'property' => $property->getProperty()); |
|
| 697 | + $groupObject=array('object'=>$value, 'property' => $property->getProperty()); |
|
| 701 | 698 | if(empty($parent)) |
| 702 | 699 | $this->_groupBy->add($group, $groupKey, $groupObject); |
| 703 | 700 | else |
@@ -715,7 +712,7 @@ discard block |
||
| 715 | 712 | */ |
| 716 | 713 | protected function getResultMapGroupKey($resultMap, $row) |
| 717 | 714 | { |
| 718 | - $groupBy = $resultMap->getGroupBy(); |
|
| 715 | + $groupBy=$resultMap->getGroupBy(); |
|
| 719 | 716 | if(isset($row[$groupBy])) |
| 720 | 717 | return $resultMap->getID().$row[$groupBy]; |
| 721 | 718 | else |
@@ -736,12 +733,12 @@ discard block |
||
| 736 | 733 | $resultObject=''; |
| 737 | 734 | |
| 738 | 735 | if($resultMap!==null) |
| 739 | - $result = $this->fillArrayResultMap($resultMap, $row, $resultObject); |
|
| 736 | + $result=$this->fillArrayResultMap($resultMap, $row, $resultObject); |
|
| 740 | 737 | else |
| 741 | - $result = $row; |
|
| 738 | + $result=$row; |
|
| 742 | 739 | |
| 743 | 740 | //if scalar result types |
| 744 | - if(count($result) == 1 && ($type = gettype($resultObject))!= 'array') |
|
| 741 | + if(count($result)==1 && ($type=gettype($resultObject))!='array') |
|
| 745 | 742 | return $this->getScalarResult($result, $type); |
| 746 | 743 | else |
| 747 | 744 | return $result; |
@@ -756,14 +753,14 @@ discard block |
||
| 756 | 753 | */ |
| 757 | 754 | protected function fillArrayResultMap($resultMap, $row, $resultObject) |
| 758 | 755 | { |
| 759 | - $result = array(); |
|
| 756 | + $result=array(); |
|
| 760 | 757 | $registry=$this->getManager()->getTypeHandlers(); |
| 761 | 758 | foreach($resultMap->getColumns() as $column) |
| 762 | 759 | { |
| 763 | 760 | if(($column->getType()===null) |
| 764 | 761 | && ($resultObject!==null) && !is_object($resultObject)) |
| 765 | 762 | $column->setType(gettype($resultObject)); |
| 766 | - $result[$column->getProperty()] = $column->getPropertyValue($registry,$row); |
|
| 763 | + $result[$column->getProperty()]=$column->getPropertyValue($registry, $row); |
|
| 767 | 764 | } |
| 768 | 765 | return $result; |
| 769 | 766 | } |
@@ -776,7 +773,7 @@ discard block |
||
| 776 | 773 | */ |
| 777 | 774 | protected function getScalarResult($result, $type) |
| 778 | 775 | { |
| 779 | - $scalar = array_shift($result); |
|
| 776 | + $scalar=array_shift($result); |
|
| 780 | 777 | settype($scalar, $type); |
| 781 | 778 | return $scalar; |
| 782 | 779 | } |
@@ -790,23 +787,23 @@ discard block |
||
| 790 | 787 | */ |
| 791 | 788 | protected function setObjectProperty($resultMap, $property, $row, &$resultObject) |
| 792 | 789 | { |
| 793 | - $select = $property->getSelect(); |
|
| 794 | - $key = $property->getProperty(); |
|
| 795 | - $nested = $property->getNestedResultMap(); |
|
| 790 | + $select=$property->getSelect(); |
|
| 791 | + $key=$property->getProperty(); |
|
| 792 | + $nested=$property->getNestedResultMap(); |
|
| 796 | 793 | $registry=$this->getManager()->getTypeHandlers(); |
| 797 | - if($key === '') |
|
| 794 | + if($key==='') |
|
| 798 | 795 | { |
| 799 | - $resultObject = $property->getPropertyValue($registry,$row); |
|
| 796 | + $resultObject=$property->getPropertyValue($registry, $row); |
|
| 800 | 797 | } |
| 801 | - else if(strlen($select) == 0 && ($nested===null)) |
|
| 798 | + else if(strlen($select)==0 && ($nested===null)) |
|
| 802 | 799 | { |
| 803 | - $value = $property->getPropertyValue($registry,$row); |
|
| 800 | + $value=$property->getPropertyValue($registry, $row); |
|
| 804 | 801 | |
| 805 | - $this->_IsRowDataFound = $this->_IsRowDataFound || ($value != null); |
|
| 802 | + $this->_IsRowDataFound=$this->_IsRowDataFound || ($value!=null); |
|
| 806 | 803 | if(is_array($resultObject) || is_object($resultObject)) |
| 807 | 804 | TPropertyAccess::set($resultObject, $key, $value); |
| 808 | 805 | else |
| 809 | - $resultObject = $value; |
|
| 806 | + $resultObject=$value; |
|
| 810 | 807 | } |
| 811 | 808 | else if($nested!==null) |
| 812 | 809 | { |
@@ -819,9 +816,9 @@ discard block |
||
| 819 | 816 | } |
| 820 | 817 | else |
| 821 | 818 | { |
| 822 | - $obj = $nested->createInstanceOfResult($this->getManager()->getTypeHandlers()); |
|
| 823 | - if($this->fillPropertyWithResultMap($nested, $row, $obj) == false) |
|
| 824 | - $obj = null; |
|
| 819 | + $obj=$nested->createInstanceOfResult($this->getManager()->getTypeHandlers()); |
|
| 820 | + if($this->fillPropertyWithResultMap($nested, $row, $obj)==false) |
|
| 821 | + $obj=null; |
|
| 825 | 822 | TPropertyAccess::set($resultObject, $key, $obj); |
| 826 | 823 | } |
| 827 | 824 | } |
@@ -841,9 +838,9 @@ discard block |
||
| 841 | 838 | */ |
| 842 | 839 | protected function enquequePostSelect($select, $resultMap, $property, $row, $resultObject) |
| 843 | 840 | { |
| 844 | - $statement = $this->getManager()->getMappedStatement($select); |
|
| 845 | - $key = $this->getPostSelectKeys($resultMap, $property, $row); |
|
| 846 | - $postSelect = new TPostSelectBinding; |
|
| 841 | + $statement=$this->getManager()->getMappedStatement($select); |
|
| 842 | + $key=$this->getPostSelectKeys($resultMap, $property, $row); |
|
| 843 | + $postSelect=new TPostSelectBinding; |
|
| 847 | 844 | $postSelect->setStatement($statement); |
| 848 | 845 | $postSelect->setResultObject($resultObject); |
| 849 | 846 | $postSelect->setResultProperty($property); |
@@ -851,10 +848,10 @@ discard block |
||
| 851 | 848 | |
| 852 | 849 | if($property->instanceOfListType($resultObject)) |
| 853 | 850 | { |
| 854 | - $values = null; |
|
| 851 | + $values=null; |
|
| 855 | 852 | if($property->getLazyLoad()) |
| 856 | 853 | { |
| 857 | - $values = TLazyLoadList::newInstance($statement, $key, |
|
| 854 | + $values=TLazyLoadList::newInstance($statement, $key, |
|
| 858 | 855 | $resultObject, $property->getProperty()); |
| 859 | 856 | TPropertyAccess::set($resultObject, $property->getProperty(), $values); |
| 860 | 857 | } |
@@ -867,7 +864,7 @@ discard block |
||
| 867 | 864 | $postSelect->setMethod(self::QUERY_FOR_OBJECT); |
| 868 | 865 | |
| 869 | 866 | if(!$property->getLazyLoad()) |
| 870 | - $this->_selectQueue[] = $postSelect; |
|
| 867 | + $this->_selectQueue[]=$postSelect; |
|
| 871 | 868 | } |
| 872 | 869 | |
| 873 | 870 | /** |
@@ -877,23 +874,23 @@ discard block |
||
| 877 | 874 | * @param array current row data. |
| 878 | 875 | * @return array list of primary key values. |
| 879 | 876 | */ |
| 880 | - protected function getPostSelectKeys($resultMap, $property,$row) |
|
| 877 | + protected function getPostSelectKeys($resultMap, $property, $row) |
|
| 881 | 878 | { |
| 882 | - $value = $property->getColumn(); |
|
| 883 | - if(is_int(strpos($value.',',0)) || is_int(strpos($value, '=',0))) |
|
| 879 | + $value=$property->getColumn(); |
|
| 880 | + if(is_int(strpos($value.',', 0)) || is_int(strpos($value, '=', 0))) |
|
| 884 | 881 | { |
| 885 | - $keys = array(); |
|
| 882 | + $keys=array(); |
|
| 886 | 883 | foreach(explode(',', $value) as $entry) |
| 887 | 884 | { |
| 888 | - $pair =explode('=',$entry); |
|
| 889 | - $keys[trim($pair[0])] = $row[trim($pair[1])]; |
|
| 885 | + $pair=explode('=', $entry); |
|
| 886 | + $keys[trim($pair[0])]=$row[trim($pair[1])]; |
|
| 890 | 887 | } |
| 891 | 888 | return $keys; |
| 892 | 889 | } |
| 893 | 890 | else |
| 894 | 891 | { |
| 895 | 892 | $registry=$this->getManager()->getTypeHandlers(); |
| 896 | - return $property->getPropertyValue($registry,$row); |
|
| 893 | + return $property->getPropertyValue($registry, $row); |
|
| 897 | 894 | } |
| 898 | 895 | } |
| 899 | 896 | |
@@ -906,29 +903,29 @@ discard block |
||
| 906 | 903 | */ |
| 907 | 904 | protected function fillPropertyWithResultMap($resultMap, $row, &$resultObject) |
| 908 | 905 | { |
| 909 | - $dataFound = false; |
|
| 906 | + $dataFound=false; |
|
| 910 | 907 | foreach($resultMap->getColumns() as $property) |
| 911 | 908 | { |
| 912 | - $this->_IsRowDataFound = false; |
|
| 909 | + $this->_IsRowDataFound=false; |
|
| 913 | 910 | $this->setObjectProperty($resultMap, $property, $row, $resultObject); |
| 914 | - $dataFound = $dataFound || $this->_IsRowDataFound; |
|
| 911 | + $dataFound=$dataFound || $this->_IsRowDataFound; |
|
| 915 | 912 | } |
| 916 | - $this->_IsRowDataFound = $dataFound; |
|
| 913 | + $this->_IsRowDataFound=$dataFound; |
|
| 917 | 914 | return $dataFound; |
| 918 | 915 | } |
| 919 | 916 | |
| 920 | 917 | public function __wakeup() |
| 921 | 918 | { |
| 922 | - if (is_null($this->_selectQueue)) $this->_selectQueue = array(); |
|
| 919 | + if(is_null($this->_selectQueue)) $this->_selectQueue=array(); |
|
| 923 | 920 | } |
| 924 | 921 | |
| 925 | 922 | public function __sleep() |
| 926 | 923 | { |
| 927 | - $exprops = array(); $cn = __CLASS__; |
|
| 928 | - if (!count($this->_selectQueue)) $exprops[] = "\0$cn\0_selectQueue"; |
|
| 929 | - if (is_null($this->_groupBy)) $exprops[] = "\0$cn\0_groupBy"; |
|
| 930 | - if (!$this->_IsRowDataFound) $exprops[] = "\0$cn\0_IsRowDataFound"; |
|
| 931 | - return array_diff(parent::__sleep(),$exprops); |
|
| 924 | + $exprops=array(); $cn=__CLASS__; |
|
| 925 | + if(!count($this->_selectQueue)) $exprops[]="\0$cn\0_selectQueue"; |
|
| 926 | + if(is_null($this->_groupBy)) $exprops[]="\0$cn\0_groupBy"; |
|
| 927 | + if(!$this->_IsRowDataFound) $exprops[]="\0$cn\0_IsRowDataFound"; |
|
| 928 | + return array_diff(parent::__sleep(), $exprops); |
|
| 932 | 929 | } |
| 933 | 930 | } |
| 934 | 931 | |
@@ -947,20 +944,20 @@ discard block |
||
| 947 | 944 | private $_keys=null; |
| 948 | 945 | private $_method=TMappedStatement::QUERY_FOR_LIST; |
| 949 | 946 | |
| 950 | - public function getStatement(){ return $this->_statement; } |
|
| 951 | - public function setStatement($value){ $this->_statement = $value; } |
|
| 947 | + public function getStatement() { return $this->_statement; } |
|
| 948 | + public function setStatement($value) { $this->_statement=$value; } |
|
| 952 | 949 | |
| 953 | - public function getResultProperty(){ return $this->_property; } |
|
| 954 | - public function setResultProperty($value){ $this->_property = $value; } |
|
| 950 | + public function getResultProperty() { return $this->_property; } |
|
| 951 | + public function setResultProperty($value) { $this->_property=$value; } |
|
| 955 | 952 | |
| 956 | - public function getResultObject(){ return $this->_resultObject; } |
|
| 957 | - public function setResultObject($value){ $this->_resultObject = $value; } |
|
| 953 | + public function getResultObject() { return $this->_resultObject; } |
|
| 954 | + public function setResultObject($value) { $this->_resultObject=$value; } |
|
| 958 | 955 | |
| 959 | - public function getKeys(){ return $this->_keys; } |
|
| 960 | - public function setKeys($value){ $this->_keys = $value; } |
|
| 956 | + public function getKeys() { return $this->_keys; } |
|
| 957 | + public function setKeys($value) { $this->_keys=$value; } |
|
| 961 | 958 | |
| 962 | - public function getMethod(){ return $this->_method; } |
|
| 963 | - public function setMethod($value){ $this->_method = $value; } |
|
| 959 | + public function getMethod() { return $this->_method; } |
|
| 960 | + public function setMethod($value) { $this->_method=$value; } |
|
| 964 | 961 | } |
| 965 | 962 | |
| 966 | 963 | /** |
@@ -979,22 +976,22 @@ discard block |
||
| 979 | 976 | /** |
| 980 | 977 | * @var array object graph as tree |
| 981 | 978 | */ |
| 982 | - private $_tree = array(); |
|
| 979 | + private $_tree=array(); |
|
| 983 | 980 | /** |
| 984 | 981 | * @var array tree node values |
| 985 | 982 | */ |
| 986 | - private $_entries = array(); |
|
| 983 | + private $_entries=array(); |
|
| 987 | 984 | /** |
| 988 | 985 | * @var array resulting object collection |
| 989 | 986 | */ |
| 990 | - private $_list = array(); |
|
| 987 | + private $_list=array(); |
|
| 991 | 988 | |
| 992 | 989 | /** |
| 993 | 990 | * @return boolean true if the graph is empty |
| 994 | 991 | */ |
| 995 | 992 | public function isEmpty() |
| 996 | 993 | { |
| 997 | - return count($this->_entries) == 0; |
|
| 994 | + return count($this->_entries)==0; |
|
| 998 | 995 | } |
| 999 | 996 | |
| 1000 | 997 | /** |
@@ -1008,22 +1005,22 @@ discard block |
||
| 1008 | 1005 | if(isset($this->_entries[$parent]) && ($this->_entries[$parent]!==null) |
| 1009 | 1006 | && isset($this->_entries[$node]) && ($this->_entries[$node]!==null)) |
| 1010 | 1007 | { |
| 1011 | - $this->_entries[$node] = $object; |
|
| 1008 | + $this->_entries[$node]=$object; |
|
| 1012 | 1009 | return; |
| 1013 | 1010 | } |
| 1014 | - $this->_entries[$node] = $object; |
|
| 1011 | + $this->_entries[$node]=$object; |
|
| 1015 | 1012 | if(empty($parent)) |
| 1016 | 1013 | { |
| 1017 | 1014 | if(isset($this->_entries[$node])) |
| 1018 | 1015 | return; |
| 1019 | - $this->_tree[$node] = array(); |
|
| 1016 | + $this->_tree[$node]=array(); |
|
| 1020 | 1017 | } |
| 1021 | - $found = $this->addNode($this->_tree, $parent, $node); |
|
| 1018 | + $found=$this->addNode($this->_tree, $parent, $node); |
|
| 1022 | 1019 | if(!$found && !empty($parent)) |
| 1023 | 1020 | { |
| 1024 | - $this->_tree[$parent] = array(); |
|
| 1025 | - if(!isset($this->_entries[$parent]) || $object !== '') |
|
| 1026 | - $this->_entries[$parent] = $object; |
|
| 1021 | + $this->_tree[$parent]=array(); |
|
| 1022 | + if(!isset($this->_entries[$parent]) || $object!=='') |
|
| 1023 | + $this->_entries[$parent]=$object; |
|
| 1027 | 1024 | $this->addNode($this->_tree, $parent, $node); |
| 1028 | 1025 | } |
| 1029 | 1026 | } |
@@ -1037,20 +1034,20 @@ discard block |
||
| 1037 | 1034 | */ |
| 1038 | 1035 | protected function addNode(&$childs, $parent, $node) |
| 1039 | 1036 | { |
| 1040 | - $found = false; |
|
| 1037 | + $found=false; |
|
| 1041 | 1038 | reset($childs); |
| 1042 | - for($i = 0, $k = count($childs); $i < $k; $i++) |
|
| 1039 | + for($i=0, $k=count($childs); $i < $k; $i++) |
|
| 1043 | 1040 | { |
| 1044 | - $key = key($childs); |
|
| 1041 | + $key=key($childs); |
|
| 1045 | 1042 | next($childs); |
| 1046 | - if($key == $parent) |
|
| 1043 | + if($key==$parent) |
|
| 1047 | 1044 | { |
| 1048 | - $found = true; |
|
| 1049 | - $childs[$key][$node] = array(); |
|
| 1045 | + $found=true; |
|
| 1046 | + $childs[$key][$node]=array(); |
|
| 1050 | 1047 | } |
| 1051 | 1048 | else |
| 1052 | 1049 | { |
| 1053 | - $found = $found || $this->addNode($childs[$key], $parent, $node); |
|
| 1050 | + $found=$found || $this->addNode($childs[$key], $parent, $node); |
|
| 1054 | 1051 | } |
| 1055 | 1052 | } |
| 1056 | 1053 | return $found; |
@@ -1072,9 +1069,9 @@ discard block |
||
| 1072 | 1069 | */ |
| 1073 | 1070 | protected function hasChildren(&$nodes) |
| 1074 | 1071 | { |
| 1075 | - $hasChildren = false; |
|
| 1072 | + $hasChildren=false; |
|
| 1076 | 1073 | foreach($nodes as $node) |
| 1077 | - if(count($node) != 0) |
|
| 1074 | + if(count($node)!=0) |
|
| 1078 | 1075 | return true; |
| 1079 | 1076 | return $hasChildren; |
| 1080 | 1077 | } |
@@ -1086,14 +1083,14 @@ discard block |
||
| 1086 | 1083 | */ |
| 1087 | 1084 | protected function collectChildren($parent, &$nodes) |
| 1088 | 1085 | { |
| 1089 | - $noChildren = !$this->hasChildren($nodes); |
|
| 1090 | - $childs = array(); |
|
| 1091 | - for(reset($nodes); $key = key($nodes);) |
|
| 1086 | + $noChildren=!$this->hasChildren($nodes); |
|
| 1087 | + $childs=array(); |
|
| 1088 | + for(reset($nodes); $key=key($nodes);) |
|
| 1092 | 1089 | { |
| 1093 | 1090 | next($nodes); |
| 1094 | 1091 | if($noChildren) |
| 1095 | 1092 | { |
| 1096 | - $childs[] = $key; |
|
| 1093 | + $childs[]=$key; |
|
| 1097 | 1094 | unset($nodes[$key]); |
| 1098 | 1095 | } |
| 1099 | 1096 | else |
@@ -1113,17 +1110,17 @@ discard block |
||
| 1113 | 1110 | if(empty($parent) || empty($this->_entries[$parent])) |
| 1114 | 1111 | return; |
| 1115 | 1112 | |
| 1116 | - $parentObject = $this->_entries[$parent]['object']; |
|
| 1117 | - $property = $this->_entries[$nodes[0]]['property']; |
|
| 1113 | + $parentObject=$this->_entries[$parent]['object']; |
|
| 1114 | + $property=$this->_entries[$nodes[0]]['property']; |
|
| 1118 | 1115 | |
| 1119 | - $list = TPropertyAccess::get($parentObject, $property); |
|
| 1116 | + $list=TPropertyAccess::get($parentObject, $property); |
|
| 1120 | 1117 | |
| 1121 | 1118 | foreach($nodes as $node) |
| 1122 | 1119 | { |
| 1123 | 1120 | if($list instanceof TList) |
| 1124 | - $parentObject->{$property}[] = $this->_entries[$node]['object']; |
|
| 1121 | + $parentObject->{$property}[]=$this->_entries[$node]['object']; |
|
| 1125 | 1122 | else if(is_array($list)) |
| 1126 | - $list[] = $this->_entries[$node]['object']; |
|
| 1123 | + $list[]=$this->_entries[$node]['object']; |
|
| 1127 | 1124 | else |
| 1128 | 1125 | throw new TSqlMapExecutionException( |
| 1129 | 1126 | 'sqlmap_property_must_be_list'); |
@@ -1132,8 +1129,8 @@ discard block |
||
| 1132 | 1129 | if(is_array($list)) |
| 1133 | 1130 | TPropertyAccess::set($parentObject, $property, $list); |
| 1134 | 1131 | |
| 1135 | - if($this->_entries[$parent]['property'] === null) |
|
| 1136 | - $this->_list[] = $parentObject; |
|
| 1132 | + if($this->_entries[$parent]['property']===null) |
|
| 1133 | + $this->_list[]=$parentObject; |
|
| 1137 | 1134 | } |
| 1138 | 1135 | |
| 1139 | 1136 | /** |
@@ -1146,11 +1143,11 @@ discard block |
||
| 1146 | 1143 | |
| 1147 | 1144 | public function __sleep() |
| 1148 | 1145 | { |
| 1149 | - $exprops = array(); $cn = __CLASS__; |
|
| 1150 | - if (!count($this->_tree)) $exprops[] = "\0$cn\0_tree"; |
|
| 1151 | - if (!count($this->_entries)) $exprops[] = "\0$cn\0_entries"; |
|
| 1152 | - if (!count($this->_list)) $exprops[] = "\0$cn\0_list"; |
|
| 1153 | - return array_diff(parent::__sleep(),$exprops); |
|
| 1146 | + $exprops=array(); $cn=__CLASS__; |
|
| 1147 | + if(!count($this->_tree)) $exprops[]="\0$cn\0_tree"; |
|
| 1148 | + if(!count($this->_entries)) $exprops[]="\0$cn\0_entries"; |
|
| 1149 | + if(!count($this->_list)) $exprops[]="\0$cn\0_list"; |
|
| 1150 | + return array_diff(parent::__sleep(), $exprops); |
|
| 1154 | 1151 | } |
| 1155 | 1152 | } |
| 1156 | 1153 | |
@@ -1169,9 +1166,9 @@ discard block |
||
| 1169 | 1166 | |
| 1170 | 1167 | public function __construct($result, $parameter, &$list) |
| 1171 | 1168 | { |
| 1172 | - $this->_resultObject = $result; |
|
| 1173 | - $this->_parameterObject = $parameter; |
|
| 1174 | - $this->_list = &$list; |
|
| 1169 | + $this->_resultObject=$result; |
|
| 1170 | + $this->_parameterObject=$parameter; |
|
| 1171 | + $this->_list=&$list; |
|
| 1175 | 1172 | } |
| 1176 | 1173 | |
| 1177 | 1174 | public function getResult() |
@@ -1206,10 +1203,10 @@ discard block |
||
| 1206 | 1203 | |
| 1207 | 1204 | public function __construct($key, $value, $parameter, &$map) |
| 1208 | 1205 | { |
| 1209 | - $this->_key = $key; |
|
| 1210 | - $this->_value = $value; |
|
| 1211 | - $this->_parameterObject = $parameter; |
|
| 1212 | - $this->_map = &$map; |
|
| 1206 | + $this->_key=$key; |
|
| 1207 | + $this->_value=$value; |
|
| 1208 | + $this->_parameterObject=$parameter; |
|
| 1209 | + $this->_map=&$map; |
|
| 1213 | 1210 | } |
| 1214 | 1211 | |
| 1215 | 1212 | public function getKey() |
@@ -21,6 +21,9 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | class TPreparedCommand |
| 23 | 23 | { |
| 24 | + /** |
|
| 25 | + * @param TSqlMapStatement $statement |
|
| 26 | + */ |
|
| 24 | 27 | public function create(TSqlMapManager $manager, $connection, $statement, $parameterObject,$skip=null,$max=null) |
| 25 | 28 | { |
| 26 | 29 | $sqlText = $statement->getSQLText(); |
@@ -43,6 +46,9 @@ discard block |
||
| 43 | 46 | return $command; |
| 44 | 47 | } |
| 45 | 48 | |
| 49 | + /** |
|
| 50 | + * @param TSqlMapManager $manager |
|
| 51 | + */ |
|
| 46 | 52 | protected function applyParameterMap($manager,$command,$prepared, $statement, $parameterObject) |
| 47 | 53 | { |
| 48 | 54 | $properties = $prepared->getParameterNames(false); |
@@ -21,45 +21,45 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class TPreparedCommand |
| 23 | 23 | { |
| 24 | - public function create(TSqlMapManager $manager, $connection, $statement, $parameterObject,$skip=null,$max=null) |
|
| 24 | + public function create(TSqlMapManager $manager, $connection, $statement, $parameterObject, $skip=null, $max=null) |
|
| 25 | 25 | { |
| 26 | - $sqlText = $statement->getSQLText(); |
|
| 26 | + $sqlText=$statement->getSQLText(); |
|
| 27 | 27 | |
| 28 | - $prepared = $sqlText->getPreparedStatement($parameterObject); |
|
| 28 | + $prepared=$sqlText->getPreparedStatement($parameterObject); |
|
| 29 | 29 | $connection->setActive(true); |
| 30 | - $sql = $prepared->getPreparedSql(); |
|
| 30 | + $sql=$prepared->getPreparedSql(); |
|
| 31 | 31 | |
| 32 | 32 | if($sqlText instanceof TSimpleDynamicSql) |
| 33 | - $sql = $sqlText->replaceDynamicParameter($sql, $parameterObject); |
|
| 33 | + $sql=$sqlText->replaceDynamicParameter($sql, $parameterObject); |
|
| 34 | 34 | |
| 35 | 35 | if($max!==null || $skip!==null) |
| 36 | 36 | { |
| 37 | - $builder = TDbMetaData::getInstance($connection)->createCommandBuilder(); |
|
| 38 | - $sql = $builder->applyLimitOffset($sql,$max,$skip); |
|
| 37 | + $builder=TDbMetaData::getInstance($connection)->createCommandBuilder(); |
|
| 38 | + $sql=$builder->applyLimitOffset($sql, $max, $skip); |
|
| 39 | 39 | } |
| 40 | - $command = $connection->createCommand($sql); |
|
| 40 | + $command=$connection->createCommand($sql); |
|
| 41 | 41 | $this->applyParameterMap($manager, $command, $prepared, $statement, $parameterObject); |
| 42 | 42 | |
| 43 | 43 | return $command; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - protected function applyParameterMap($manager,$command,$prepared, $statement, $parameterObject) |
|
| 46 | + protected function applyParameterMap($manager, $command, $prepared, $statement, $parameterObject) |
|
| 47 | 47 | { |
| 48 | - $properties = $prepared->getParameterNames(false); |
|
| 48 | + $properties=$prepared->getParameterNames(false); |
|
| 49 | 49 | //$parameters = $prepared->getParameterValues(); |
| 50 | 50 | $registry=$manager->getTypeHandlers(); |
| 51 | - if ($properties) |
|
| 52 | - for($i = 0, $k=$properties->getCount(); $i<$k; $i++) |
|
| 51 | + if($properties) |
|
| 52 | + for($i=0, $k=$properties->getCount(); $i < $k; $i++) |
|
| 53 | 53 | { |
| 54 | - $property = $statement->parameterMap()->getProperty($i); |
|
| 55 | - $value = $statement->parameterMap()->getPropertyValue($registry,$property, $parameterObject); |
|
| 56 | - $dbType = $property->getDbType(); |
|
| 54 | + $property=$statement->parameterMap()->getProperty($i); |
|
| 55 | + $value=$statement->parameterMap()->getPropertyValue($registry, $property, $parameterObject); |
|
| 56 | + $dbType=$property->getDbType(); |
|
| 57 | 57 | if($dbType=='') //relies on PHP lax comparison |
| 58 | - $command->bindValue($i+1,$value, TDbCommandBuilder::getPdoType($value)); |
|
| 58 | + $command->bindValue($i + 1, $value, TDbCommandBuilder::getPdoType($value)); |
|
| 59 | 59 | else if(strpos($dbType, 'PDO::')===0) |
| 60 | - $command->bindValue($i+1,$value, constant($property->getDbType())); //assumes PDO types, e.g. PDO::PARAM_INT |
|
| 60 | + $command->bindValue($i + 1, $value, constant($property->getDbType())); //assumes PDO types, e.g. PDO::PARAM_INT |
|
| 61 | 61 | else |
| 62 | - $command->bindValue($i+1,$value); |
|
| 62 | + $command->bindValue($i + 1, $value); |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -77,6 +77,7 @@ |
||
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * Saves the current SqlMap manager to cache. |
| 80 | + * @param TSqlMapManager $manager |
|
| 80 | 81 | * @return boolean true if SqlMap manager was cached, false otherwise. |
| 81 | 82 | */ |
| 82 | 83 | protected function cacheSqlMapManager($manager) |
@@ -68,8 +68,7 @@ |
||
| 68 | 68 | $manager->configureXml($file); |
| 69 | 69 | $this->cacheSqlMapManager($manager); |
| 70 | 70 | } |
| 71 | - } |
|
| 72 | - elseif($this->getConnectionID() !== '') { |
|
| 71 | + } elseif($this->getConnectionID() !== '') { |
|
| 73 | 72 | $manager->setDbConnection($this->getDbConnection()); |
| 74 | 73 | } |
| 75 | 74 | return $manager; |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function clearCache() |
| 46 | 46 | { |
| 47 | - $cache = $this->getApplication()->getCache(); |
|
| 48 | - if($cache !== null) { |
|
| 47 | + $cache=$this->getApplication()->getCache(); |
|
| 48 | + if($cache!==null) { |
|
| 49 | 49 | $cache->delete($this->getCacheKey()); |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -60,16 +60,16 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function getSqlMapManager() { |
| 62 | 62 | Prado::using('System.Data.SqlMap.TSqlMapManager'); |
| 63 | - if(($manager = $this->loadCachedSqlMapManager())===null) |
|
| 63 | + if(($manager=$this->loadCachedSqlMapManager())===null) |
|
| 64 | 64 | { |
| 65 | - $manager = new TSqlMapManager($this->getDbConnection()); |
|
| 65 | + $manager=new TSqlMapManager($this->getDbConnection()); |
|
| 66 | 66 | if(strlen($file=$this->getConfigFile()) > 0) |
| 67 | 67 | { |
| 68 | 68 | $manager->configureXml($file); |
| 69 | 69 | $this->cacheSqlMapManager($manager); |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | - elseif($this->getConnectionID() !== '') { |
|
| 72 | + elseif($this->getConnectionID()!=='') { |
|
| 73 | 73 | $manager->setDbConnection($this->getDbConnection()); |
| 74 | 74 | } |
| 75 | 75 | return $manager; |
@@ -83,11 +83,11 @@ discard block |
||
| 83 | 83 | { |
| 84 | 84 | if($this->getEnableCache()) |
| 85 | 85 | { |
| 86 | - $cache = $this->getApplication()->getCache(); |
|
| 87 | - if($cache !== null) { |
|
| 88 | - $dependencies = null; |
|
| 89 | - if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
| 90 | - $dependencies = $manager->getCacheDependencies(); |
|
| 86 | + $cache=$this->getApplication()->getCache(); |
|
| 87 | + if($cache!==null) { |
|
| 88 | + $dependencies=null; |
|
| 89 | + if($this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
| 90 | + $dependencies=$manager->getCacheDependencies(); |
|
| 91 | 91 | return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -102,10 +102,10 @@ discard block |
||
| 102 | 102 | { |
| 103 | 103 | if($this->getEnableCache()) |
| 104 | 104 | { |
| 105 | - $cache = $this->getApplication()->getCache(); |
|
| 106 | - if($cache !== null) |
|
| 105 | + $cache=$this->getApplication()->getCache(); |
|
| 106 | + if($cache!==null) |
|
| 107 | 107 | { |
| 108 | - $manager = $cache->get($this->getCacheKey()); |
|
| 108 | + $manager=$cache->get($this->getCacheKey()); |
|
| 109 | 109 | if($manager instanceof TSqlMapManager) |
| 110 | 110 | return $manager; |
| 111 | 111 | } |
@@ -132,11 +132,11 @@ discard block |
||
| 132 | 132 | $this->_configFile=$value; |
| 133 | 133 | else |
| 134 | 134 | { |
| 135 | - $file = Prado::getPathOfNamespace($value,self::CONFIG_FILE_EXT); |
|
| 136 | - if($file === null || !is_file($file)) |
|
| 137 | - throw new TConfigurationException('sqlmap_configfile_invalid',$value); |
|
| 135 | + $file=Prado::getPathOfNamespace($value, self::CONFIG_FILE_EXT); |
|
| 136 | + if($file===null || !is_file($file)) |
|
| 137 | + throw new TConfigurationException('sqlmap_configfile_invalid', $value); |
|
| 138 | 138 | else |
| 139 | - $this->_configFile = $file; |
|
| 139 | + $this->_configFile=$file; |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function setEnableCache($value) |
| 148 | 148 | { |
| 149 | - $this->_enableCache = TPropertyValue::ensureBoolean($value); |
|
| 149 | + $this->_enableCache=TPropertyValue::ensureBoolean($value); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | public function getClient() |
| 173 | 173 | { |
| 174 | - if($this->_sqlmap===null ) |
|
| 174 | + if($this->_sqlmap===null) |
|
| 175 | 175 | $this->_sqlmap=$this->createSqlMapGateway(); |
| 176 | 176 | return $this->_sqlmap; |
| 177 | 177 | } |
@@ -55,6 +55,7 @@ discard block |
||
| 55 | 55 | * Constructor, create a new SqlMap manager. |
| 56 | 56 | * @param TDbConnection database connection |
| 57 | 57 | * @param string configuration file. |
| 58 | + * @param TDbConnection $connection |
|
| 58 | 59 | */ |
| 59 | 60 | public function __construct($connection=null) |
| 60 | 61 | { |
@@ -68,6 +69,7 @@ discard block |
||
| 68 | 69 | |
| 69 | 70 | /** |
| 70 | 71 | * @param TDbConnection default database connection |
| 72 | + * @param TComponent $conn |
|
| 71 | 73 | */ |
| 72 | 74 | public function setDbConnection($conn) |
| 73 | 75 | { |
@@ -105,6 +107,7 @@ discard block |
||
| 105 | 107 | /** |
| 106 | 108 | * Loads and parses the SqlMap configuration file. |
| 107 | 109 | * @param string xml configuration file. |
| 110 | + * @param string $file |
|
| 108 | 111 | */ |
| 109 | 112 | public function configureXml($file) |
| 110 | 113 | { |
@@ -180,6 +183,7 @@ discard block |
||
| 180 | 183 | /** |
| 181 | 184 | * Gets a named result map |
| 182 | 185 | * @param string result name. |
| 186 | + * @param string $name |
|
| 183 | 187 | * @return TResultMap the result map. |
| 184 | 188 | * @throws TSqlMapUndefinedException |
| 185 | 189 | */ |
@@ -212,6 +216,7 @@ discard block |
||
| 212 | 216 | |
| 213 | 217 | /** |
| 214 | 218 | * @param string parameter map ID name. |
| 219 | + * @param string $name |
|
| 215 | 220 | * @return TParameterMap the parameter with given ID. |
| 216 | 221 | * @throws TSqlMapUndefinedException |
| 217 | 222 | */ |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | public function getTypeHandlers() |
| 89 | 89 | { |
| 90 | 90 | if($this->_typeHandlers===null) |
| 91 | - $this->_typeHandlers= new TSqlMapTypeHandlerRegistry(); |
|
| 91 | + $this->_typeHandlers=new TSqlMapTypeHandlerRegistry(); |
|
| 92 | 92 | return $this->_typeHandlers; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function configureXml($file) |
| 110 | 110 | { |
| 111 | - $config = new TSqlMapXmlConfiguration($this); |
|
| 111 | + $config=new TSqlMapXmlConfiguration($this); |
|
| 112 | 112 | $config->configure($file); |
| 113 | 113 | } |
| 114 | 114 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function getCacheDependencies() |
| 120 | 120 | { |
| 121 | - if($this->_cacheDependencies === null) |
|
| 121 | + if($this->_cacheDependencies===null) |
|
| 122 | 122 | $this->_cacheDependencies=new TChainedCacheDependency(); |
| 123 | 123 | |
| 124 | 124 | return $this->_cacheDependencies; |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | public function getMappedStatement($name) |
| 152 | 152 | { |
| 153 | - if($this->_mappedStatements->contains($name) == false) |
|
| 153 | + if($this->_mappedStatements->contains($name)==false) |
|
| 154 | 154 | throw new TSqlMapUndefinedException('sqlmap_contains_no_statement', $name); |
| 155 | 155 | return $this->_mappedStatements[$name]; |
| 156 | 156 | } |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public function addMappedStatement(IMappedStatement $statement) |
| 165 | 165 | { |
| 166 | - $key = $statement->getID(); |
|
| 167 | - if($this->_mappedStatements->contains($key) == true) |
|
| 166 | + $key=$statement->getID(); |
|
| 167 | + if($this->_mappedStatements->contains($key)==true) |
|
| 168 | 168 | throw new TSqlMapDuplicateException('sqlmap_already_contains_statement', $key); |
| 169 | 169 | $this->_mappedStatements->add($key, $statement); |
| 170 | 170 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | public function getResultMap($name) |
| 187 | 187 | { |
| 188 | - if($this->_resultMaps->contains($name) == false) |
|
| 188 | + if($this->_resultMaps->contains($name)==false) |
|
| 189 | 189 | throw new TSqlMapUndefinedException('sqlmap_contains_no_result_map', $name); |
| 190 | 190 | return $this->_resultMaps[$name]; |
| 191 | 191 | } |
@@ -196,8 +196,8 @@ discard block |
||
| 196 | 196 | */ |
| 197 | 197 | public function addResultMap(TResultMap $result) |
| 198 | 198 | { |
| 199 | - $key = $result->getID(); |
|
| 200 | - if($this->_resultMaps->contains($key) == true) |
|
| 199 | + $key=$result->getID(); |
|
| 200 | + if($this->_resultMaps->contains($key)==true) |
|
| 201 | 201 | throw new TSqlMapDuplicateException('sqlmap_already_contains_result_map', $key); |
| 202 | 202 | $this->_resultMaps->add($key, $result); |
| 203 | 203 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | public function getParameterMap($name) |
| 219 | 219 | { |
| 220 | - if($this->_parameterMaps->contains($name) == false) |
|
| 220 | + if($this->_parameterMaps->contains($name)==false) |
|
| 221 | 221 | throw new TSqlMapUndefinedException('sqlmap_contains_no_parameter_map', $name); |
| 222 | 222 | return $this->_parameterMaps[$name]; |
| 223 | 223 | } |
@@ -228,8 +228,8 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | public function addParameterMap(TParameterMap $parameter) |
| 230 | 230 | { |
| 231 | - $key = $parameter->getID(); |
|
| 232 | - if($this->_parameterMaps->contains($key) == true) |
|
| 231 | + $key=$parameter->getID(); |
|
| 232 | + if($this->_parameterMaps->contains($key)==true) |
|
| 233 | 233 | throw new TSqlMapDuplicateException('sqlmap_already_contains_parameter_map', $key); |
| 234 | 234 | $this->_parameterMaps->add($key, $parameter); |
| 235 | 235 | } |
@@ -149,6 +149,7 @@ |
||
| 149 | 149 | /** |
| 150 | 150 | * Finds the database connection instance from the Application modules. |
| 151 | 151 | * @param string Database connection module ID. |
| 152 | + * @param string $id |
|
| 152 | 153 | * @return TDbConnection database connection. |
| 153 | 154 | * @throws TConfigurationException when module is not of TDbConnection or TDataSourceConfig. |
| 154 | 155 | */ |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | { |
| 63 | 63 | $db=$this->getDbConnection(); |
| 64 | 64 | foreach($xml['database'] as $name=>$value) |
| 65 | - $db->setSubProperty($name,$value); |
|
| 65 | + $db->setSubProperty($name, $value); |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | else |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | $db=$this->getDbConnection(); |
| 73 | 73 | foreach($prop->getAttributes() as $name=>$value) |
| 74 | - $db->setSubproperty($name,$value); |
|
| 74 | + $db->setSubproperty($name, $value); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -106,9 +106,9 @@ discard block |
||
| 106 | 106 | if($this->_conn===null) |
| 107 | 107 | { |
| 108 | 108 | if($this->_connID!=='') |
| 109 | - $this->_conn = $this->findConnectionByID($this->getConnectionID()); |
|
| 109 | + $this->_conn=$this->findConnectionByID($this->getConnectionID()); |
|
| 110 | 110 | else |
| 111 | - $this->_conn = Prado::createComponent($this->getConnectionClass()); |
|
| 111 | + $this->_conn=Prado::createComponent($this->getConnectionClass()); |
|
| 112 | 112 | } |
| 113 | 113 | return $this->_conn; |
| 114 | 114 | } |
@@ -154,12 +154,12 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | protected function findConnectionByID($id) |
| 156 | 156 | { |
| 157 | - $conn = $this->getApplication()->getModule($id); |
|
| 157 | + $conn=$this->getApplication()->getModule($id); |
|
| 158 | 158 | if($conn instanceof TDbConnection) |
| 159 | 159 | return $conn; |
| 160 | 160 | else if($conn instanceof TDataSourceConfig) |
| 161 | 161 | return $conn->getDbConnection(); |
| 162 | 162 | else |
| 163 | - throw new TConfigurationException('datasource_dbconnection_invalid',$id); |
|
| 163 | + throw new TConfigurationException('datasource_dbconnection_invalid', $id); |
|
| 164 | 164 | } |
| 165 | 165 | } |
@@ -68,8 +68,7 @@ |
||
| 68 | 68 | foreach($xml['database'] as $name=>$value) |
| 69 | 69 | $db->setSubProperty($name,$value); |
| 70 | 70 | } |
| 71 | - } |
|
| 72 | - else |
|
| 71 | + } else |
|
| 73 | 72 | { |
| 74 | 73 | if($prop=$xml->getElementByTagName('database')) |
| 75 | 74 | { |
@@ -157,6 +157,7 @@ discard block |
||
| 157 | 157 | /** |
| 158 | 158 | * Open or close the DB connection. |
| 159 | 159 | * @param boolean whether to open or close DB connection |
| 160 | + * @param boolean $value |
|
| 160 | 161 | * @throws TDbException if connection fails |
| 161 | 162 | */ |
| 162 | 163 | public function setActive($value) |
@@ -241,6 +242,7 @@ discard block |
||
| 241 | 242 | |
| 242 | 243 | /** |
| 243 | 244 | * @param string The Data Source Name, or DSN, contains the information required to connect to the database. |
| 245 | + * @param string $value |
|
| 244 | 246 | * @see http://www.php.net/manual/en/function.PDO-construct.php |
| 245 | 247 | */ |
| 246 | 248 | public function setConnectionString($value) |
@@ -258,6 +260,7 @@ discard block |
||
| 258 | 260 | |
| 259 | 261 | /** |
| 260 | 262 | * @param string the username for establishing DB connection |
| 263 | + * @param string $value |
|
| 261 | 264 | */ |
| 262 | 265 | public function setUsername($value) |
| 263 | 266 | { |
@@ -274,6 +277,7 @@ discard block |
||
| 274 | 277 | |
| 275 | 278 | /** |
| 276 | 279 | * @param string the password for establishing DB connection |
| 280 | + * @param string $value |
|
| 277 | 281 | */ |
| 278 | 282 | public function setPassword($value) |
| 279 | 283 | { |
@@ -189,8 +189,7 @@ discard block |
||
| 189 | 189 | $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 190 | 190 | $this->_active=true; |
| 191 | 191 | $this->setConnectionCharset(); |
| 192 | - } |
|
| 193 | - catch(PDOException $e) |
|
| 192 | + } catch(PDOException $e) |
|
| 194 | 193 | { |
| 195 | 194 | throw new TDbException('dbconnection_open_failed',$e->getMessage()); |
| 196 | 195 | } |
@@ -343,8 +342,7 @@ discard block |
||
| 343 | 342 | { |
| 344 | 343 | $this->_pdo->beginTransaction(); |
| 345 | 344 | return $this->_transaction=Prado::createComponent($this->getTransactionClass(), $this); |
| 346 | - } |
|
| 347 | - else |
|
| 345 | + } else |
|
| 348 | 346 | throw new TDbException('dbconnection_connection_inactive'); |
| 349 | 347 | } |
| 350 | 348 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @since 3.1.7 |
| 87 | 87 | */ |
| 88 | - const DEFAULT_TRANSACTION_CLASS = 'System.Data.TDbTransaction'; |
|
| 88 | + const DEFAULT_TRANSACTION_CLASS='System.Data.TDbTransaction'; |
|
| 89 | 89 | |
| 90 | 90 | private $_dsn=''; |
| 91 | 91 | private $_username=''; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | /** |
| 100 | 100 | * @var TDbMetaData |
| 101 | 101 | */ |
| 102 | - private $_dbMeta = null; |
|
| 102 | + private $_dbMeta=null; |
|
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | 105 | * @var string |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * @param string Charset used for DB Connection (MySql & pgsql only). If not set, will use the default charset of your database server |
| 121 | 121 | * @see http://www.php.net/manual/en/function.PDO-construct.php |
| 122 | 122 | */ |
| 123 | - public function __construct($dsn='',$username='',$password='', $charset='') |
|
| 123 | + public function __construct($dsn='', $username='', $password='', $charset='') |
|
| 124 | 124 | { |
| 125 | 125 | $this->_dsn=$dsn; |
| 126 | 126 | $this->_username=$username; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | public function __sleep() |
| 135 | 135 | { |
| 136 | 136 | // $this->close(); - DO NOT CLOSE the current connection as serializing doesn't neccessarily mean we don't this connection anymore in the current session |
| 137 | - return array_diff(parent::__sleep(),array("\0TDbConnection\0_pdo","\0TDbConnection\0_active")); |
|
| 137 | + return array_diff(parent::__sleep(), array("\0TDbConnection\0_pdo", "\0TDbConnection\0_active")); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -181,8 +181,8 @@ discard block |
||
| 181 | 181 | { |
| 182 | 182 | try |
| 183 | 183 | { |
| 184 | - $this->_pdo=new PDO($this->getConnectionString(),$this->getUsername(), |
|
| 185 | - $this->getPassword(),$this->_attributes); |
|
| 184 | + $this->_pdo=new PDO($this->getConnectionString(), $this->getUsername(), |
|
| 185 | + $this->getPassword(), $this->_attributes); |
|
| 186 | 186 | // This attribute is only useful for PDO::MySql driver. |
| 187 | 187 | // Ignore the warning if a driver doesn't understand this. |
| 188 | 188 | @$this->_pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | catch(PDOException $e) |
| 194 | 194 | { |
| 195 | - throw new TDbException('dbconnection_open_failed',$e->getMessage()); |
|
| 195 | + throw new TDbException('dbconnection_open_failed', $e->getMessage()); |
|
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | } |
@@ -214,16 +214,16 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | protected function setConnectionCharset() |
| 216 | 216 | { |
| 217 | - if ($this->_charset === '' || $this->_active === false) |
|
| 217 | + if($this->_charset==='' || $this->_active===false) |
|
| 218 | 218 | return; |
| 219 | - switch ($this->_pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) |
|
| 219 | + switch($this->_pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) |
|
| 220 | 220 | { |
| 221 | 221 | case 'mysql': |
| 222 | 222 | case 'sqlite': |
| 223 | - $stmt = $this->_pdo->prepare('SET NAMES ?'); |
|
| 223 | + $stmt=$this->_pdo->prepare('SET NAMES ?'); |
|
| 224 | 224 | break; |
| 225 | 225 | case 'pgsql': |
| 226 | - $stmt = $this->_pdo->prepare('SET client_encoding TO ?'); |
|
| 226 | + $stmt=$this->_pdo->prepare('SET client_encoding TO ?'); |
|
| 227 | 227 | break; |
| 228 | 228 | default: |
| 229 | 229 | throw new TDbException('dbconnection_unsupported_driver_charset', $driver); |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | /** |
| 284 | 284 | * @return string the charset used for database connection. Defaults to emtpy string. |
| 285 | 285 | */ |
| 286 | - public function getCharset () |
|
| 286 | + public function getCharset() |
|
| 287 | 287 | { |
| 288 | 288 | return $this->_charset; |
| 289 | 289 | } |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | /** |
| 292 | 292 | * @param string the charset used for database connection |
| 293 | 293 | */ |
| 294 | - public function setCharset ($value) |
|
| 294 | + public function setCharset($value) |
|
| 295 | 295 | { |
| 296 | 296 | $this->_charset=$value; |
| 297 | 297 | $this->setConnectionCharset(); |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | public function createCommand($sql) |
| 315 | 315 | { |
| 316 | 316 | if($this->getActive()) |
| 317 | - return new TDbCommand($this,$sql); |
|
| 317 | + return new TDbCommand($this, $sql); |
|
| 318 | 318 | else |
| 319 | 319 | throw new TDbException('dbconnection_connection_inactive'); |
| 320 | 320 | } |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | */ |
| 365 | 365 | public function setTransactionClass($value) |
| 366 | 366 | { |
| 367 | - $this->_transactionClass = (string)$value; |
|
| 367 | + $this->_transactionClass=(string) $value; |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | /** |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | if($this->_dbMeta===null) |
| 434 | 434 | { |
| 435 | 435 | Prado::using('System.Data.Common.TDbMetaData'); |
| 436 | - $this->_dbMeta = TDbMetaData::getInstance($this); |
|
| 436 | + $this->_dbMeta=TDbMetaData::getInstance($this); |
|
| 437 | 437 | } |
| 438 | 438 | return $this->_dbMeta; |
| 439 | 439 | } |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | */ |
| 460 | 460 | public function setColumnCase($value) |
| 461 | 461 | { |
| 462 | - switch(TPropertyValue::ensureEnum($value,'TDbColumnCaseMode')) |
|
| 462 | + switch(TPropertyValue::ensureEnum($value, 'TDbColumnCaseMode')) |
|
| 463 | 463 | { |
| 464 | 464 | case TDbColumnCaseMode::Preserved: |
| 465 | 465 | $value=PDO::CASE_NATURAL; |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | $value=PDO::CASE_UPPER; |
| 472 | 472 | break; |
| 473 | 473 | } |
| 474 | - $this->setAttribute(PDO::ATTR_CASE,$value); |
|
| 474 | + $this->setAttribute(PDO::ATTR_CASE, $value); |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | /** |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | */ |
| 496 | 496 | public function setNullConversion($value) |
| 497 | 497 | { |
| 498 | - switch(TPropertyValue::ensureEnum($value,'TDbNullConversionMode')) |
|
| 498 | + switch(TPropertyValue::ensureEnum($value, 'TDbNullConversionMode')) |
|
| 499 | 499 | { |
| 500 | 500 | case TDbNullConversionMode::Preserved: |
| 501 | 501 | $value=PDO::NULL_NATURAL; |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | $value=PDO::NULL_TO_STRING; |
| 508 | 508 | break; |
| 509 | 509 | } |
| 510 | - $this->setAttribute(PDO::ATTR_ORACLE_NULLS,$value); |
|
| 510 | + $this->setAttribute(PDO::ATTR_ORACLE_NULLS, $value); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | /** |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | */ |
| 526 | 526 | public function setAutoCommit($value) |
| 527 | 527 | { |
| 528 | - $this->setAttribute(PDO::ATTR_AUTOCOMMIT,TPropertyValue::ensureBoolean($value)); |
|
| 528 | + $this->setAttribute(PDO::ATTR_AUTOCOMMIT, TPropertyValue::ensureBoolean($value)); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | /** |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | */ |
| 544 | 544 | public function setPersistent($value) |
| 545 | 545 | { |
| 546 | - return $this->setAttribute(PDO::ATTR_PERSISTENT,TPropertyValue::ensureBoolean($value)); |
|
| 546 | + return $this->setAttribute(PDO::ATTR_PERSISTENT, TPropertyValue::ensureBoolean($value)); |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | /** |
@@ -623,10 +623,10 @@ discard block |
||
| 623 | 623 | * @param mixed the attribute value |
| 624 | 624 | * @see http://www.php.net/manual/en/function.PDO-setAttribute.php |
| 625 | 625 | */ |
| 626 | - public function setAttribute($name,$value) |
|
| 626 | + public function setAttribute($name, $value) |
|
| 627 | 627 | { |
| 628 | 628 | if($this->_pdo instanceof PDO) |
| 629 | - $this->_pdo->setAttribute($name,$value); |
|
| 629 | + $this->_pdo->setAttribute($name, $value); |
|
| 630 | 630 | else |
| 631 | 631 | $this->_attributes[$name]=$value; |
| 632 | 632 | } |