@@ -297,18 +297,18 @@ |
||
297 | 297 | { |
298 | 298 | $cn = __CLASS__; |
299 | 299 | $exprops = ["\0$cn\0_resultMap"]; |
300 | - if (!$this->_parameterMapName) $exprops[] = "\0$cn\0_parameterMapName"; |
|
301 | - if (!$this->_parameterMap) $exprops[] = "\0$cn\0_parameterMap"; |
|
302 | - if (!$this->_parameterClassName) $exprops[] = "\0$cn\0_parameterClassName"; |
|
303 | - if (!$this->_resultMapName) $exprops[] = "\0$cn\0_resultMapName"; |
|
304 | - if (!$this->_resultMap) $exprops[] = "\0$cn\0_resultMap"; |
|
305 | - if (!$this->_resultClassName) $exprops[] = "\0$cn\0_resultClassName"; |
|
306 | - if (!$this->_cacheModelName) $exprops[] = "\0$cn\0_cacheModelName"; |
|
307 | - if (!$this->_SQL) $exprops[] = "\0$cn\0_SQL"; |
|
308 | - if (!$this->_listClass) $exprops[] = "\0$cn\0_listClass"; |
|
309 | - if (!$this->_typeHandler) $exprops[] = "\0$cn\0_typeHandler"; |
|
310 | - if (!$this->_extendStatement) $exprops[] = "\0$cn\0_extendStatement"; |
|
311 | - if (!$this->_cache) $exprops[] = "\0$cn\0_cache"; |
|
300 | + if(!$this->_parameterMapName) $exprops[] = "\0$cn\0_parameterMapName"; |
|
301 | + if(!$this->_parameterMap) $exprops[] = "\0$cn\0_parameterMap"; |
|
302 | + if(!$this->_parameterClassName) $exprops[] = "\0$cn\0_parameterClassName"; |
|
303 | + if(!$this->_resultMapName) $exprops[] = "\0$cn\0_resultMapName"; |
|
304 | + if(!$this->_resultMap) $exprops[] = "\0$cn\0_resultMap"; |
|
305 | + if(!$this->_resultClassName) $exprops[] = "\0$cn\0_resultClassName"; |
|
306 | + if(!$this->_cacheModelName) $exprops[] = "\0$cn\0_cacheModelName"; |
|
307 | + if(!$this->_SQL) $exprops[] = "\0$cn\0_SQL"; |
|
308 | + if(!$this->_listClass) $exprops[] = "\0$cn\0_listClass"; |
|
309 | + if(!$this->_typeHandler) $exprops[] = "\0$cn\0_typeHandler"; |
|
310 | + if(!$this->_extendStatement) $exprops[] = "\0$cn\0_extendStatement"; |
|
311 | + if(!$this->_cache) $exprops[] = "\0$cn\0_cache"; |
|
312 | 312 | |
313 | 313 | return array_diff(parent::__sleep(), $exprops); |
314 | 314 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function setImplementation($value) |
83 | 83 | { |
84 | - if (isset(self::$_cacheTypes[$value])) |
|
84 | + if(isset(self::$_cacheTypes[$value])) |
|
85 | 85 | $this->_implementation = $value; |
86 | 86 | else |
87 | 87 | $this->_implementation = TPropertyValue::ensureEnum($value, 'Prado\\Data\\SqlMap\\Configuration\\TSqlMapCacheTypes'); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | public function getImplementationClass() |
122 | 122 | { |
123 | 123 | $implementation = $this->_implementation; |
124 | - if (isset(self::$_cacheTypes[$implementation])) return self::$_cacheTypes[$implementation]; |
|
124 | + if(isset(self::$_cacheTypes[$implementation])) return self::$_cacheTypes[$implementation]; |
|
125 | 125 | |
126 | 126 | switch(TPropertyValue::ensureEnum($implementation, 'Prado\\Data\\SqlMap\\Configuration\\TSqlMapCacheTypes')) |
127 | 127 | { |
@@ -23,6 +23,6 @@ |
||
23 | 23 | { |
24 | 24 | private $_generate; |
25 | 25 | |
26 | - public function getGenerate(){ return $this->_generate; } |
|
27 | - public function setGenerate($value){ $this->_generate = $value; } |
|
26 | + public function getGenerate() { return $this->_generate; } |
|
27 | + public function setGenerate($value) { $this->_generate = $value; } |
|
28 | 28 | } |
29 | 29 | \ No newline at end of file |
@@ -85,32 +85,41 @@ discard block |
||
85 | 85 | ->getDependencies() |
86 | 86 | ->add(new TFileCacheDependency($filename)); |
87 | 87 | |
88 | - foreach($document->xpath('//resultMap') as $node) |
|
89 | - $this->loadResultMap($node); |
|
88 | + foreach($document->xpath('//resultMap') as $node) { |
|
89 | + $this->loadResultMap($node); |
|
90 | + } |
|
90 | 91 | |
91 | - foreach($document->xpath('//parameterMap') as $node) |
|
92 | - $this->loadParameterMap($node); |
|
92 | + foreach($document->xpath('//parameterMap') as $node) { |
|
93 | + $this->loadParameterMap($node); |
|
94 | + } |
|
93 | 95 | |
94 | - foreach($document->xpath('//statement') as $node) |
|
95 | - $this->loadStatementTag($node); |
|
96 | + foreach($document->xpath('//statement') as $node) { |
|
97 | + $this->loadStatementTag($node); |
|
98 | + } |
|
96 | 99 | |
97 | - foreach($document->xpath('//select') as $node) |
|
98 | - $this->loadSelectTag($node); |
|
100 | + foreach($document->xpath('//select') as $node) { |
|
101 | + $this->loadSelectTag($node); |
|
102 | + } |
|
99 | 103 | |
100 | - foreach($document->xpath('//insert') as $node) |
|
101 | - $this->loadInsertTag($node); |
|
104 | + foreach($document->xpath('//insert') as $node) { |
|
105 | + $this->loadInsertTag($node); |
|
106 | + } |
|
102 | 107 | |
103 | - foreach($document->xpath('//update') as $node) |
|
104 | - $this->loadUpdateTag($node); |
|
108 | + foreach($document->xpath('//update') as $node) { |
|
109 | + $this->loadUpdateTag($node); |
|
110 | + } |
|
105 | 111 | |
106 | - foreach($document->xpath('//delete') as $node) |
|
107 | - $this->loadDeleteTag($node); |
|
112 | + foreach($document->xpath('//delete') as $node) { |
|
113 | + $this->loadDeleteTag($node); |
|
114 | + } |
|
108 | 115 | |
109 | - foreach($document->xpath('//procedure') as $node) |
|
110 | - $this->loadProcedureTag($node); |
|
116 | + foreach($document->xpath('//procedure') as $node) { |
|
117 | + $this->loadProcedureTag($node); |
|
118 | + } |
|
111 | 119 | |
112 | - foreach($document->xpath('//cacheModel') as $node) |
|
113 | - $this->loadCacheModel($node); |
|
120 | + foreach($document->xpath('//cacheModel') as $node) { |
|
121 | + $this->loadCacheModel($node); |
|
122 | + } |
|
114 | 123 | |
115 | 124 | $this->registerCacheTriggers(); |
116 | 125 | } |
@@ -213,8 +222,9 @@ discard block |
||
213 | 222 | 'sqlmap_unable_to_find_parent_parameter_map', $node, $this->_configFile, $extendMap); |
214 | 223 | $superMap = $this->_manager->getParameterMap($extendMap); |
215 | 224 | $index = 0; |
216 | - foreach($superMap->getPropertyNames() as $propertyName) |
|
217 | - $parameterMap->insertProperty($index++, $superMap->getProperty($propertyName)); |
|
225 | + foreach($superMap->getPropertyNames() as $propertyName) { |
|
226 | + $parameterMap->insertProperty($index++, $superMap->getProperty($propertyName)); |
|
227 | + } |
|
218 | 228 | } |
219 | 229 | $this->_manager->addParameterMap($parameterMap); |
220 | 230 | } |
@@ -296,8 +306,9 @@ discard block |
||
296 | 306 | $map = new TParameterMap(); |
297 | 307 | $map->setID($statement->getID() . '-InLineParameterMap'); |
298 | 308 | $statement->setInlineParameterMap($map); |
299 | - foreach($sqlText['parameters'] as $property) |
|
300 | - $map->addProperty($property); |
|
309 | + foreach($sqlText['parameters'] as $property) { |
|
310 | + $map->addProperty($property); |
|
311 | + } |
|
301 | 312 | } |
302 | 313 | $sqlStatement = $sqlText['sql']; |
303 | 314 | } |
@@ -322,8 +333,7 @@ discard block |
||
322 | 333 | { |
323 | 334 | $sql = new TSimpleDynamicSql($dynamics['parameters']); |
324 | 335 | $sqlStatement = $dynamics['sql']; |
325 | - } |
|
326 | - else |
|
336 | + } else |
|
327 | 337 | $sql = new TStaticSql(); |
328 | 338 | $sqlStatement = preg_replace('/' . self::SIMPLE_PLACEHOLDER . '/', self::SIMPLE_MARK, $sqlStatement); |
329 | 339 | $sql->buildPreparedStatement($statement, $sqlStatement); |
@@ -457,8 +467,9 @@ discard block |
||
457 | 467 | |
458 | 468 | $cacheModel->initialize($cache); |
459 | 469 | $this->_manager->addCacheModel($cacheModel); |
460 | - foreach($node->xpath('flushOnExecute') as $flush) |
|
461 | - $this->loadFlushOnCache($cacheModel, $node, $flush); |
|
470 | + foreach($node->xpath('flushOnExecute') as $flush) { |
|
471 | + $this->loadFlushOnCache($cacheModel, $node, $flush); |
|
472 | + } |
|
462 | 473 | } |
463 | 474 | |
464 | 475 | /** |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | */ |
259 | 259 | protected function processSqlStatement($statement, $node) |
260 | 260 | { |
261 | - $commandText = (string)$node; |
|
261 | + $commandText = (string) $node; |
|
262 | 262 | if(strlen($extend = $statement->getExtends()) > 0) |
263 | 263 | { |
264 | 264 | $superNode = $this->getElementByIdValue($this->_document, '*', $extend); |
265 | 265 | if($superNode !== null) |
266 | - $commandText = (string)$superNode . $commandText; |
|
266 | + $commandText = (string) $superNode . $commandText; |
|
267 | 267 | else |
268 | 268 | throw new TSqlMapConfigurationException( |
269 | 269 | 'sqlmap_unable_to_find_parent_sql', $extend, $this->_configFile, $node); |
@@ -431,11 +431,11 @@ discard block |
||
431 | 431 | protected function loadCacheModel($node) |
432 | 432 | { |
433 | 433 | $cacheModel = new TSqlMapCacheModel; |
434 | - $properties = ['id','implementation']; |
|
434 | + $properties = ['id', 'implementation']; |
|
435 | 435 | foreach($node->attributes() as $name => $value) |
436 | 436 | { |
437 | 437 | if(in_array(strtolower($name), $properties)) |
438 | - $cacheModel->{'set' . $name}((string)$value); |
|
438 | + $cacheModel->{'set' . $name}((string) $value); |
|
439 | 439 | } |
440 | 440 | $cache = Prado::createComponent($cacheModel->getImplementationClass(), $cacheModel); |
441 | 441 | $this->setObjectPropFromNode($cache, $node, $properties); |
@@ -476,19 +476,19 @@ discard block |
||
476 | 476 | switch(strToLower($name)) |
477 | 477 | { |
478 | 478 | case 'seconds': |
479 | - $duration += (integer)$value; |
|
479 | + $duration += (integer) $value; |
|
480 | 480 | break; |
481 | 481 | case 'minutes': |
482 | - $duration += 60 * (integer)$value; |
|
482 | + $duration += 60 * (integer) $value; |
|
483 | 483 | break; |
484 | 484 | case 'hours': |
485 | - $duration += 3600 * (integer)$value; |
|
485 | + $duration += 3600 * (integer) $value; |
|
486 | 486 | break; |
487 | 487 | case 'days': |
488 | - $duration += 86400 * (integer)$value; |
|
488 | + $duration += 86400 * (integer) $value; |
|
489 | 489 | break; |
490 | 490 | case 'duration': |
491 | - $duration = (integer)$value; |
|
491 | + $duration = (integer) $value; |
|
492 | 492 | break 2; // switch, foreach |
493 | 493 | } |
494 | 494 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | foreach($node->attributes() as $name => $value) |
510 | 510 | { |
511 | 511 | if(strtolower($name) === 'statement') |
512 | - $this->_FlushOnExecuteStatements[$id][] = (string)$value; |
|
512 | + $this->_FlushOnExecuteStatements[$id][] = (string) $value; |
|
513 | 513 | } |
514 | 514 | } |
515 | 515 |
@@ -64,21 +64,25 @@ discard block |
||
64 | 64 | $this->_configFile = $filename; |
65 | 65 | $document = $this->loadXmlDocument($filename, $this); |
66 | 66 | |
67 | - foreach($document->xpath('//property') as $property) |
|
68 | - $this->loadGlobalProperty($property); |
|
67 | + foreach($document->xpath('//property') as $property) { |
|
68 | + $this->loadGlobalProperty($property); |
|
69 | + } |
|
69 | 70 | |
70 | - foreach($document->xpath('//typeHandler') as $handler) |
|
71 | - $this->loadTypeHandler($handler); |
|
71 | + foreach($document->xpath('//typeHandler') as $handler) { |
|
72 | + $this->loadTypeHandler($handler); |
|
73 | + } |
|
72 | 74 | |
73 | - foreach($document->xpath('//connection[last()]') as $conn) |
|
74 | - $this->loadDatabaseConnection($conn); |
|
75 | + foreach($document->xpath('//connection[last()]') as $conn) { |
|
76 | + $this->loadDatabaseConnection($conn); |
|
77 | + } |
|
75 | 78 | |
76 | 79 | //try to load configuration in the current config file. |
77 | 80 | $mapping = new TSqlMapXmlMappingConfiguration($this); |
78 | 81 | $mapping->configure($filename); |
79 | 82 | |
80 | - foreach($document->xpath('//sqlMap') as $sqlmap) |
|
81 | - $this->loadSqlMappingFiles($sqlmap); |
|
83 | + foreach($document->xpath('//sqlMap') as $sqlmap) { |
|
84 | + $this->loadSqlMappingFiles($sqlmap); |
|
85 | + } |
|
82 | 86 | |
83 | 87 | $this->resolveResultMapping(); |
84 | 88 | $this->attachCacheModels(); |
@@ -179,8 +183,9 @@ discard block |
||
179 | 183 | */ |
180 | 184 | public function replaceProperties($string) |
181 | 185 | { |
182 | - foreach($this->_properties as $find => $replace) |
|
183 | - $string = str_replace('${' . $find . '}', $replace, $string); |
|
186 | + foreach($this->_properties as $find => $replace) { |
|
187 | + $string = str_replace('${' . $find . '}', $replace, $string); |
|
188 | + } |
|
184 | 189 | return $string; |
185 | 190 | } |
186 | 191 | } |
187 | 192 | \ No newline at end of file |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected function loadGlobalProperty($node) |
92 | 92 | { |
93 | - $this->_properties[(string)$node['name']] = (string)$node['value']; |
|
93 | + $this->_properties[(string) $node['name']] = (string) $node['value']; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | protected function loadSqlMappingFiles($node) |
121 | 121 | { |
122 | - if(strlen($resource = (string)$node['resource']) > 0) |
|
122 | + if(strlen($resource = (string) $node['resource']) > 0) |
|
123 | 123 | { |
124 | 124 | if(strpos($resource, '${') !== false) |
125 | 125 | $resource = $this->replaceProperties($resource); |
@@ -108,8 +108,9 @@ |
||
108 | 108 | foreach(['id','ID','Id', 'iD'] as $id) |
109 | 109 | { |
110 | 110 | $xpath = "//{$tag}[@{$id}='{$value}']"; |
111 | - foreach($document->xpath($xpath) as $node) |
|
112 | - return $node; |
|
111 | + foreach($document->xpath($xpath) as $node) { |
|
112 | + return $node; |
|
113 | + } |
|
113 | 114 | } |
114 | 115 | } |
115 | 116 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | { |
34 | 34 | if(isset($node['class'])) |
35 | 35 | { |
36 | - $obj = Prado::createComponent((string)$node['class']); |
|
36 | + $obj = Prado::createComponent((string) $node['class']); |
|
37 | 37 | $this->setObjectPropFromNode($obj, $node, ['class']); |
38 | 38 | return $obj; |
39 | 39 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | if(!in_array($name, $except)) |
56 | 56 | { |
57 | 57 | if($obj->canSetProperty($name)) |
58 | - $obj->{$name} = (string)$value; |
|
58 | + $obj->{$name} = (string) $value; |
|
59 | 59 | else |
60 | 60 | throw new TSqlMapConfigurationException( |
61 | 61 | 'sqlmap_invalid_property', $name, get_class($obj), |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | protected function getElementByIdValue($document, $tag, $value) |
106 | 106 | { |
107 | 107 | //hack to allow upper case and lower case attribute names. |
108 | - foreach(['id','ID','Id', 'iD'] as $id) |
|
108 | + foreach(['id', 'ID', 'Id', 'iD'] as $id) |
|
109 | 109 | { |
110 | 110 | $xpath = "//{$tag}[@{$id}='{$value}']"; |
111 | 111 | foreach($document->xpath($xpath) as $node) |
@@ -199,9 +199,9 @@ |
||
199 | 199 | public function __sleep() |
200 | 200 | { |
201 | 201 | $exprops = []; $cn = __CLASS__; |
202 | - if (!count($this->_tree)) $exprops[] = "\0$cn\0_tree"; |
|
203 | - if (!count($this->_entries)) $exprops[] = "\0$cn\0_entries"; |
|
204 | - if (!count($this->_list)) $exprops[] = "\0$cn\0_list"; |
|
202 | + if(!count($this->_tree)) $exprops[] = "\0$cn\0_tree"; |
|
203 | + if(!count($this->_entries)) $exprops[] = "\0$cn\0_entries"; |
|
204 | + if(!count($this->_list)) $exprops[] = "\0$cn\0_list"; |
|
205 | 205 | return array_diff(parent::__sleep(), $exprops); |
206 | 206 | } |
207 | 207 | } |
208 | 208 | \ No newline at end of file |
@@ -99,8 +99,7 @@ discard block |
||
99 | 99 | { |
100 | 100 | $found = true; |
101 | 101 | $childs[$key][$node] = []; |
102 | - } |
|
103 | - else |
|
102 | + } else |
|
104 | 103 | { |
105 | 104 | $found = $found || $this->addNode($childs[$key], $parent, $node); |
106 | 105 | } |
@@ -113,8 +112,9 @@ discard block |
||
113 | 112 | */ |
114 | 113 | public function collect() |
115 | 114 | { |
116 | - while(count($this->_tree) > 0) |
|
117 | - $this->collectChildren(null, $this->_tree); |
|
115 | + while(count($this->_tree) > 0) { |
|
116 | + $this->collectChildren(null, $this->_tree); |
|
117 | + } |
|
118 | 118 | return $this->getCollection(); |
119 | 119 | } |
120 | 120 | |
@@ -125,9 +125,10 @@ discard block |
||
125 | 125 | protected function hasChildren(&$nodes) |
126 | 126 | { |
127 | 127 | $hasChildren = false; |
128 | - foreach($nodes as $node) |
|
129 | - if(count($node) != 0) |
|
128 | + foreach($nodes as $node) { |
|
129 | + if(count($node) != 0) |
|
130 | 130 | return true; |
131 | + } |
|
131 | 132 | return $hasChildren; |
132 | 133 | } |
133 | 134 | |
@@ -147,8 +148,7 @@ discard block |
||
147 | 148 | { |
148 | 149 | $childs[] = $key; |
149 | 150 | unset($nodes[$key]); |
150 | - } |
|
151 | - else |
|
151 | + } else |
|
152 | 152 | $this->collectChildren($key, $nodes[$key]); |
153 | 153 | } |
154 | 154 | if(count($childs) > 0) |
@@ -47,7 +47,7 @@ |
||
47 | 47 | public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty = null, $skip = -1, $max = -1, $delegate = null) |
48 | 48 | { |
49 | 49 | $sql = $this->createCommand($connection, $parameter, $skip, $max); |
50 | - $key = $this->getCacheKey([clone($sql), $keyProperty, $valueProperty,$skip, $max]); |
|
50 | + $key = $this->getCacheKey([clone($sql), $keyProperty, $valueProperty, $skip, $max]); |
|
51 | 51 | $map = $this->getStatement()->getCache()->get($key); |
52 | 52 | if($map === null) |
53 | 53 | { |
@@ -250,8 +250,7 @@ discard block |
||
250 | 250 | $param = new TResultSetListItemParameter($obj, $parameter, $list); |
251 | 251 | $this->raiseRowDelegate($delegate, $param); |
252 | 252 | } |
253 | - } |
|
254 | - else |
|
253 | + } else |
|
255 | 254 | { |
256 | 255 | //var_dump($sql,$parameter); |
257 | 256 | foreach($reader as $row) |
@@ -327,8 +326,7 @@ discard block |
||
327 | 326 | $param = new TResultSetMapItemParameter($key, $value, $parameter, $map); |
328 | 327 | $this->raiseRowDelegate($delegate, $param); |
329 | 328 | } |
330 | - } |
|
331 | - else |
|
329 | + } else |
|
332 | 330 | { |
333 | 331 | //while($row = $recordSet->fetchRow()) |
334 | 332 | foreach($reader as $row) |
@@ -354,8 +352,7 @@ discard block |
||
354 | 352 | if(is_string($handler)) |
355 | 353 | { |
356 | 354 | call_user_func($handler, $this, $param); |
357 | - } |
|
358 | - elseif(is_callable($handler, true)) |
|
355 | + } elseif(is_callable($handler, true)) |
|
359 | 356 | { |
360 | 357 | // an array: 0 - object, 1 - method name/path |
361 | 358 | list($object, $method) = $handler; |
@@ -370,8 +367,7 @@ discard block |
||
370 | 367 | } |
371 | 368 | $object->$method($this, $param); |
372 | 369 | } |
373 | - } |
|
374 | - else |
|
370 | + } else |
|
375 | 371 | throw new TInvalidDataValueException('sqlmap_invalid_delegate', $this->getID(), $handler); |
376 | 372 | } |
377 | 373 | |
@@ -406,8 +402,9 @@ discard block |
||
406 | 402 | { |
407 | 403 | $object = null; |
408 | 404 | $connection->setActive(true); |
409 | - foreach($command->query() as $row) |
|
410 | - $object = $this->applyResultMap($row, $result); |
|
405 | + foreach($command->query() as $row) { |
|
406 | + $object = $this->applyResultMap($row, $result); |
|
407 | + } |
|
411 | 408 | |
412 | 409 | if(!$this->_groupBy->isEmpty()) |
413 | 410 | { |
@@ -533,8 +530,7 @@ discard block |
||
533 | 530 | if($method == self::QUERY_FOR_ARRAY) |
534 | 531 | $values = $values->toArray(); |
535 | 532 | TPropertyAccess::set($resultObject, $property, $values); |
536 | - } |
|
537 | - elseif($method == self::QUERY_FOR_OBJECT) |
|
533 | + } elseif($method == self::QUERY_FOR_OBJECT) |
|
538 | 534 | { |
539 | 535 | $value = $statement->executeQueryForObject($connection, $keys, null); |
540 | 536 | TPropertyAccess::set($resultObject, $property, $value); |
@@ -609,11 +605,13 @@ discard block |
||
609 | 605 | protected function fillResultArrayList($row, $resultObject) |
610 | 606 | { |
611 | 607 | if($resultObject instanceof TList) |
612 | - foreach($row as $v) |
|
613 | - $resultObject[] = $v; |
|
608 | + foreach($row as $v) { |
|
609 | + $resultObject[] = $v; |
|
610 | + } |
|
614 | 611 | else |
615 | - foreach($row as $k => $v) |
|
616 | - $resultObject[$k] = $v; |
|
612 | + foreach($row as $k => $v) { |
|
613 | + $resultObject[$k] = $v; |
|
614 | + } |
|
617 | 615 | return $resultObject; |
618 | 616 | } |
619 | 617 | |
@@ -662,10 +660,10 @@ discard block |
||
662 | 660 | if(strlen($resultMap->getGroupBy()) > 0) |
663 | 661 | return $this->addResultMapGroupBy($resultMap, $row, $parentGroup, $resultObject); |
664 | 662 | else |
665 | - foreach($resultMap->getColumns() as $property) |
|
666 | - $this->setObjectProperty($resultMap, $property, $row, $resultObject); |
|
667 | - } |
|
668 | - else |
|
663 | + foreach($resultMap->getColumns() as $property) { |
|
664 | + $this->setObjectProperty($resultMap, $property, $row, $resultObject); |
|
665 | + } |
|
666 | + } else |
|
669 | 667 | { |
670 | 668 | $resultObject = $this->fillDefaultResultMap($resultMap, $row, $resultObject); |
671 | 669 | } |
@@ -810,8 +808,7 @@ discard block |
||
810 | 808 | if($key === '') |
811 | 809 | { |
812 | 810 | $resultObject = $property->getPropertyValue($registry, $row); |
813 | - } |
|
814 | - elseif(strlen($select) == 0 && ($nested === null)) |
|
811 | + } elseif(strlen($select) == 0 && ($nested === null)) |
|
815 | 812 | { |
816 | 813 | $value = $property->getPropertyValue($registry, $row); |
817 | 814 | |
@@ -820,8 +817,7 @@ discard block |
||
820 | 817 | TPropertyAccess::set($resultObject, $key, $value); |
821 | 818 | else |
822 | 819 | $resultObject = $value; |
823 | - } |
|
824 | - elseif($nested !== null) |
|
820 | + } elseif($nested !== null) |
|
825 | 821 | { |
826 | 822 | if($property->instanceOfListType($resultObject) || $property->instanceOfArrayType($resultObject)) |
827 | 823 | { |
@@ -829,16 +825,14 @@ discard block |
||
829 | 825 | throw new TSqlMapExecutionException( |
830 | 826 | 'sqlmap_non_groupby_array_list_type', $resultMap->getID(), |
831 | 827 | get_class($resultObject), $key); |
832 | - } |
|
833 | - else |
|
828 | + } else |
|
834 | 829 | { |
835 | 830 | $obj = $nested->createInstanceOfResult($this->getManager()->getTypeHandlers()); |
836 | 831 | if($this->fillPropertyWithResultMap($nested, $row, $obj) == false) |
837 | 832 | $obj = null; |
838 | 833 | TPropertyAccess::set($resultObject, $key, $obj); |
839 | 834 | } |
840 | - } |
|
841 | - else //'select' ResultProperty |
|
835 | + } else //'select' ResultProperty |
|
842 | 836 | { |
843 | 837 | $this->enquequePostSelect($select, $resultMap, $property, $row, $resultObject); |
844 | 838 | } |
@@ -870,11 +864,9 @@ discard block |
||
870 | 864 | $values = TLazyLoadList::newInstance($statement, $key, |
871 | 865 | $resultObject, $property->getProperty()); |
872 | 866 | TPropertyAccess::set($resultObject, $property->getProperty(), $values); |
873 | - } |
|
874 | - else |
|
867 | + } else |
|
875 | 868 | $postSelect->setMethod(self::QUERY_FOR_LIST); |
876 | - } |
|
877 | - elseif($property->instanceOfArrayType($resultObject)) |
|
869 | + } elseif($property->instanceOfArrayType($resultObject)) |
|
878 | 870 | $postSelect->setMethod(self::QUERY_FOR_ARRAY); |
879 | 871 | else |
880 | 872 | $postSelect->setMethod(self::QUERY_FOR_OBJECT); |
@@ -902,8 +894,7 @@ discard block |
||
902 | 894 | $keys[trim($pair[0])] = $row[trim($pair[1])]; |
903 | 895 | } |
904 | 896 | return $keys; |
905 | - } |
|
906 | - else |
|
897 | + } else |
|
907 | 898 | { |
908 | 899 | $registry = $this->getManager()->getTypeHandlers(); |
909 | 900 | return $property->getPropertyValue($registry, $row); |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | { |
177 | 177 | if($max > -1 || $skip > -1) |
178 | 178 | { |
179 | - $maxStr = $max > 0?' LIMIT ' . $max:''; |
|
180 | - $skipStr = $skip > 0?' OFFSET ' . $skip:''; |
|
179 | + $maxStr = $max > 0 ? ' LIMIT ' . $max : ''; |
|
180 | + $skipStr = $skip > 0 ? ' OFFSET ' . $skip : ''; |
|
181 | 181 | $command->setText($command->getText() . $maxStr . $skipStr); |
182 | 182 | } |
183 | 183 | $connection->setActive(true); |
@@ -237,8 +237,7 @@ discard block |
||
237 | 237 | public function runQueryForList($connection, $parameter, $sql, $result, $delegate = null) |
238 | 238 | { |
239 | 239 | $registry = $this->getManager()->getTypeHandlers(); |
240 | - $list = $result instanceof \ArrayAccess ? $result : |
|
241 | - $this->_statement->createInstanceOfListClass($registry); |
|
240 | + $list = $result instanceof \ArrayAccess ? $result : $this->_statement->createInstanceOfListClass($registry); |
|
242 | 241 | $connection->setActive(true); |
243 | 242 | $reader = $sql->query(); |
244 | 243 | //$reader = $this->executeSQLQueryLimit($connection, $sql, $max, $skip); |
@@ -322,8 +321,7 @@ discard block |
||
322 | 321 | { |
323 | 322 | $obj = $this->applyResultMap($row); |
324 | 323 | $key = TPropertyAccess::get($obj, $keyProperty); |
325 | - $value = ($valueProperty === null) ? $obj : |
|
326 | - TPropertyAccess::get($obj, $valueProperty); |
|
324 | + $value = ($valueProperty === null) ? $obj : TPropertyAccess::get($obj, $valueProperty); |
|
327 | 325 | $param = new TResultSetMapItemParameter($key, $value, $parameter, $map); |
328 | 326 | $this->raiseRowDelegate($delegate, $param); |
329 | 327 | } |
@@ -335,8 +333,7 @@ discard block |
||
335 | 333 | { |
336 | 334 | $obj = $this->applyResultMap($row); |
337 | 335 | $key = TPropertyAccess::get($obj, $keyProperty); |
338 | - $map[$key] = ($valueProperty === null) ? $obj : |
|
339 | - TPropertyAccess::get($obj, $valueProperty); |
|
336 | + $map[$key] = ($valueProperty === null) ? $obj : TPropertyAccess::get($obj, $valueProperty); |
|
340 | 337 | } |
341 | 338 | } |
342 | 339 | $this->onExecuteQuery($command); |
@@ -932,15 +929,15 @@ discard block |
||
932 | 929 | |
933 | 930 | public function __wakeup() |
934 | 931 | { |
935 | - if (null === $this->_selectQueue) $this->_selectQueue = []; |
|
932 | + if(null === $this->_selectQueue) $this->_selectQueue = []; |
|
936 | 933 | } |
937 | 934 | |
938 | 935 | public function __sleep() |
939 | 936 | { |
940 | 937 | $exprops = []; $cn = __CLASS__; |
941 | - if (!count($this->_selectQueue)) $exprops[] = "\0$cn\0_selectQueue"; |
|
942 | - if (null === $this->_groupBy) $exprops[] = "\0$cn\0_groupBy"; |
|
943 | - if (!$this->_IsRowDataFound) $exprops[] = "\0$cn\0_IsRowDataFound"; |
|
938 | + if(!count($this->_selectQueue)) $exprops[] = "\0$cn\0_selectQueue"; |
|
939 | + if(null === $this->_groupBy) $exprops[] = "\0$cn\0_groupBy"; |
|
940 | + if(!$this->_IsRowDataFound) $exprops[] = "\0$cn\0_IsRowDataFound"; |
|
944 | 941 | return array_diff(parent::__sleep(), $exprops); |
945 | 942 | } |
946 | 943 | } |
947 | 944 | \ No newline at end of file |