@@ -38,6 +38,7 @@ |
||
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @param TSqlMapManager manager instance. |
41 | + * @param \Prado\Data\SqlMap\TSqlMapManager $manager |
|
41 | 42 | */ |
42 | 43 | public function __construct($manager) |
43 | 44 | { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | public function configure($filename=null) |
62 | 62 | { |
63 | 63 | $this->_configFile=$filename; |
64 | - $document = $this->loadXmlDocument($filename,$this); |
|
64 | + $document=$this->loadXmlDocument($filename, $this); |
|
65 | 65 | |
66 | 66 | foreach($document->xpath('//property') as $property) |
67 | 67 | $this->loadGlobalProperty($property); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $this->loadDatabaseConnection($conn); |
74 | 74 | |
75 | 75 | //try to load configuration in the current config file. |
76 | - $mapping = new TSqlMapXmlMappingConfiguration($this); |
|
76 | + $mapping=new TSqlMapXmlMappingConfiguration($this); |
|
77 | 77 | $mapping->configure($filename); |
78 | 78 | |
79 | 79 | foreach($document->xpath('//sqlMap') as $sqlmap) |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | protected function loadGlobalProperty($node) |
91 | 91 | { |
92 | - $this->_properties[(string)$node['name']] = (string)$node['value']; |
|
92 | + $this->_properties[(string) $node['name']]=(string) $node['value']; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | protected function loadTypeHandler($node) |
100 | 100 | { |
101 | - $handler = $this->createObjectFromNode($node); |
|
101 | + $handler=$this->createObjectFromNode($node); |
|
102 | 102 | $this->_manager->getTypeHandlers()->registerTypeHandler($handler); |
103 | 103 | } |
104 | 104 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | protected function loadDatabaseConnection($node) |
110 | 110 | { |
111 | - $conn = $this->createObjectFromNode($node); |
|
111 | + $conn=$this->createObjectFromNode($node); |
|
112 | 112 | $this->_manager->setDbConnection($conn); |
113 | 113 | } |
114 | 114 | |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected function loadSqlMappingFiles($node) |
120 | 120 | { |
121 | - if(strlen($resource = (string)$node['resource']) > 0) |
|
121 | + if(strlen($resource=(string) $node['resource']) > 0) |
|
122 | 122 | { |
123 | - if( strpos($resource, '${') !== false) |
|
124 | - $resource = $this->replaceProperties($resource); |
|
123 | + if(strpos($resource, '${')!==false) |
|
124 | + $resource=$this->replaceProperties($resource); |
|
125 | 125 | |
126 | - $mapping = new TSqlMapXmlMappingConfiguration($this); |
|
127 | - $filename = $this->getAbsoluteFilePath($this->_configFile, $resource); |
|
126 | + $mapping=new TSqlMapXmlMappingConfiguration($this); |
|
127 | + $filename=$this->getAbsoluteFilePath($this->_configFile, $resource); |
|
128 | 128 | $mapping->configure($filename); |
129 | 129 | } |
130 | 130 | } |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | */ |
135 | 135 | protected function resolveResultMapping() |
136 | 136 | { |
137 | - $maps = $this->_manager->getResultMaps(); |
|
137 | + $maps=$this->_manager->getResultMaps(); |
|
138 | 138 | foreach($maps as $entry) |
139 | 139 | { |
140 | 140 | foreach($entry->getColumns() as $item) |
141 | 141 | { |
142 | - $resultMap = $item->getResultMapping(); |
|
142 | + $resultMap=$item->getResultMapping(); |
|
143 | 143 | if(strlen($resultMap) > 0) |
144 | 144 | { |
145 | 145 | if($maps->contains($resultMap)) |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | { |
163 | 163 | foreach($this->_manager->getMappedStatements() as $mappedStatement) |
164 | 164 | { |
165 | - if(strlen($model = $mappedStatement->getStatement()->getCacheModel()) > 0) |
|
165 | + if(strlen($model=$mappedStatement->getStatement()->getCacheModel()) > 0) |
|
166 | 166 | { |
167 | - $cache = $this->_manager->getCacheModel($model); |
|
167 | + $cache=$this->_manager->getCacheModel($model); |
|
168 | 168 | $mappedStatement->getStatement()->setCache($cache); |
169 | 169 | } |
170 | 170 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | public function replaceProperties($string) |
180 | 180 | { |
181 | 181 | foreach($this->_properties as $find => $replace) |
182 | - $string = str_replace('${'.$find.'}', $replace, $string); |
|
182 | + $string=str_replace('${'.$find.'}', $replace, $string); |
|
183 | 183 | return $string; |
184 | 184 | } |
185 | 185 | } |
186 | 186 | \ No newline at end of file |
@@ -255,6 +255,7 @@ discard block |
||
255 | 255 | * in the sql text. Extracts inline parameter maps. |
256 | 256 | * @param TSqlMapStatement mapped statement. |
257 | 257 | * @param SimpleXmlElement statement node. |
258 | + * @param TSqlMapStatement $statement |
|
258 | 259 | */ |
259 | 260 | protected function processSqlStatement($statement, $node) |
260 | 261 | { |
@@ -278,6 +279,7 @@ discard block |
||
278 | 279 | * @param TSqlMapStatement statement object. |
279 | 280 | * @param string sql text |
280 | 281 | * @param SimpleXmlElement statement node. |
282 | + * @param string $sqlStatement |
|
281 | 283 | */ |
282 | 284 | protected function applyInlineParameterMap($statement, $sqlStatement, $node) |
283 | 285 | { |
@@ -375,6 +377,7 @@ discard block |
||
375 | 377 | /** |
376 | 378 | * Load the selectKey statement from xml mapping. |
377 | 379 | * @param SimpleXmlElement selectkey node |
380 | + * @param TSqlMapInsert $insert |
|
378 | 381 | */ |
379 | 382 | protected function loadSelectKeyTag($insert, $node) |
380 | 383 | { |
@@ -465,6 +468,7 @@ discard block |
||
465 | 468 | * Load the flush interval |
466 | 469 | * @param TSqlMapCacheModel cache model |
467 | 470 | * @param SimpleXmlElement cache node |
471 | + * @param TSqlMapCacheModel $cacheModel |
|
468 | 472 | */ |
469 | 473 | protected function loadFlushInterval($cacheModel, $node) |
470 | 474 | { |
@@ -500,6 +504,7 @@ discard block |
||
500 | 504 | * @param TSqlMapCacheModel cache model |
501 | 505 | * @param SimpleXmlElement parent node. |
502 | 506 | * @param SimpleXmlElement flush node. |
507 | + * @param TSqlMapCacheModel $cacheModel |
|
503 | 508 | */ |
504 | 509 | protected function loadFlushOnCache($cacheModel,$parent,$node) |
505 | 510 | { |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | public function configure($filename) |
74 | 74 | { |
75 | 75 | $this->_configFile=$filename; |
76 | - $document = $this->loadXmlDocument($filename,$this->_xmlConfig); |
|
76 | + $document=$this->loadXmlDocument($filename, $this->_xmlConfig); |
|
77 | 77 | $this->_document=$document; |
78 | 78 | |
79 | 79 | static $bCacheDependencies; |
80 | - if($bCacheDependencies === null) |
|
81 | - $bCacheDependencies = true; //Prado::getApplication()->getMode() !== TApplicationMode::Performance; |
|
80 | + if($bCacheDependencies===null) |
|
81 | + $bCacheDependencies=true; //Prado::getApplication()->getMode() !== TApplicationMode::Performance; |
|
82 | 82 | |
83 | 83 | if($bCacheDependencies) |
84 | 84 | $this->_manager->getCacheDependencies() |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | */ |
122 | 122 | protected function loadResultMap($node) |
123 | 123 | { |
124 | - $resultMap = $this->createResultMap($node); |
|
124 | + $resultMap=$this->createResultMap($node); |
|
125 | 125 | |
126 | 126 | //find extended result map. |
127 | - if(strlen($extendMap = $resultMap->getExtends()) > 0) |
|
127 | + if(strlen($extendMap=$resultMap->getExtends()) > 0) |
|
128 | 128 | { |
129 | 129 | if(!$this->_manager->getResultMaps()->contains($extendMap)) |
130 | 130 | { |
131 | - $extendNode=$this->getElementByIdValue($this->_document,'resultMap',$extendMap); |
|
131 | + $extendNode=$this->getElementByIdValue($this->_document, 'resultMap', $extendMap); |
|
132 | 132 | if($extendNode!==null) |
133 | 133 | $this->loadResultMap($extendNode); |
134 | 134 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | throw new TSqlMapConfigurationException( |
138 | 138 | 'sqlmap_unable_to_find_parent_result_map', $node, $this->_configFile, $extendMap); |
139 | 139 | |
140 | - $superMap = $this->_manager->getResultMap($extendMap); |
|
140 | + $superMap=$this->_manager->getResultMap($extendMap); |
|
141 | 141 | $resultMap->getColumns()->mergeWith($superMap->getColumns()); |
142 | 142 | } |
143 | 143 | |
@@ -154,22 +154,22 @@ discard block |
||
154 | 154 | */ |
155 | 155 | protected function createResultMap($node) |
156 | 156 | { |
157 | - $resultMap = new TResultMap(); |
|
158 | - $this->setObjectPropFromNode($resultMap,$node); |
|
157 | + $resultMap=new TResultMap(); |
|
158 | + $this->setObjectPropFromNode($resultMap, $node); |
|
159 | 159 | |
160 | 160 | //result nodes |
161 | 161 | foreach($node->result as $result) |
162 | 162 | { |
163 | - $property = new TResultProperty($resultMap); |
|
164 | - $this->setObjectPropFromNode($property,$result); |
|
163 | + $property=new TResultProperty($resultMap); |
|
164 | + $this->setObjectPropFromNode($property, $result); |
|
165 | 165 | $resultMap->addResultProperty($property); |
166 | 166 | } |
167 | 167 | |
168 | 168 | //create the discriminator |
169 | - $discriminator = null; |
|
169 | + $discriminator=null; |
|
170 | 170 | if(isset($node->discriminator)) |
171 | 171 | { |
172 | - $discriminator = new TDiscriminator(); |
|
172 | + $discriminator=new TDiscriminator(); |
|
173 | 173 | $this->setObjectPropFromNode($discriminator, $node->discriminator); |
174 | 174 | $discriminator->initMapping($resultMap); |
175 | 175 | } |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | { |
179 | 179 | if($discriminator===null) |
180 | 180 | throw new TSqlMapConfigurationException( |
181 | - 'sqlmap_undefined_discriminator', $node, $this->_configFile,$subMapNode); |
|
182 | - $subMap = new TSubMap; |
|
183 | - $this->setObjectPropFromNode($subMap,$subMapNode); |
|
181 | + 'sqlmap_undefined_discriminator', $node, $this->_configFile, $subMapNode); |
|
182 | + $subMap=new TSubMap; |
|
183 | + $this->setObjectPropFromNode($subMap, $subMapNode); |
|
184 | 184 | $discriminator->addSubMap($subMap); |
185 | 185 | } |
186 | 186 | |
@@ -197,24 +197,24 @@ discard block |
||
197 | 197 | */ |
198 | 198 | protected function loadParameterMap($node) |
199 | 199 | { |
200 | - $parameterMap = $this->createParameterMap($node); |
|
200 | + $parameterMap=$this->createParameterMap($node); |
|
201 | 201 | |
202 | - if(strlen($extendMap = $parameterMap->getExtends()) > 0) |
|
202 | + if(strlen($extendMap=$parameterMap->getExtends()) > 0) |
|
203 | 203 | { |
204 | 204 | if(!$this->_manager->getParameterMaps()->contains($extendMap)) |
205 | 205 | { |
206 | - $extendNode=$this->getElementByIdValue($this->_document,'parameterMap',$extendMap); |
|
206 | + $extendNode=$this->getElementByIdValue($this->_document, 'parameterMap', $extendMap); |
|
207 | 207 | if($extendNode!==null) |
208 | 208 | $this->loadParameterMap($extendNode); |
209 | 209 | } |
210 | 210 | |
211 | 211 | if(!$this->_manager->getParameterMaps()->contains($extendMap)) |
212 | 212 | throw new TSqlMapConfigurationException( |
213 | - 'sqlmap_unable_to_find_parent_parameter_map', $node, $this->_configFile,$extendMap); |
|
214 | - $superMap = $this->_manager->getParameterMap($extendMap); |
|
215 | - $index = 0; |
|
213 | + 'sqlmap_unable_to_find_parent_parameter_map', $node, $this->_configFile, $extendMap); |
|
214 | + $superMap=$this->_manager->getParameterMap($extendMap); |
|
215 | + $index=0; |
|
216 | 216 | foreach($superMap->getPropertyNames() as $propertyName) |
217 | - $parameterMap->insertProperty($index++,$superMap->getProperty($propertyName)); |
|
217 | + $parameterMap->insertProperty($index++, $superMap->getProperty($propertyName)); |
|
218 | 218 | } |
219 | 219 | $this->_manager->addParameterMap($parameterMap); |
220 | 220 | } |
@@ -226,12 +226,12 @@ discard block |
||
226 | 226 | */ |
227 | 227 | protected function createParameterMap($node) |
228 | 228 | { |
229 | - $parameterMap = new TParameterMap(); |
|
230 | - $this->setObjectPropFromNode($parameterMap,$node); |
|
229 | + $parameterMap=new TParameterMap(); |
|
230 | + $this->setObjectPropFromNode($parameterMap, $node); |
|
231 | 231 | foreach($node->parameter as $parameter) |
232 | 232 | { |
233 | - $property = new TParameterProperty(); |
|
234 | - $this->setObjectPropFromNode($property,$parameter); |
|
233 | + $property=new TParameterProperty(); |
|
234 | + $this->setObjectPropFromNode($property, $parameter); |
|
235 | 235 | $parameterMap->addProperty($property); |
236 | 236 | } |
237 | 237 | return $parameterMap; |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | */ |
244 | 244 | protected function loadStatementTag($node) |
245 | 245 | { |
246 | - $statement = new TSqlMapStatement(); |
|
247 | - $this->setObjectPropFromNode($statement,$node); |
|
246 | + $statement=new TSqlMapStatement(); |
|
247 | + $this->setObjectPropFromNode($statement, $node); |
|
248 | 248 | $this->processSqlStatement($statement, $node); |
249 | - $mappedStatement = new TMappedStatement($this->_manager, $statement); |
|
249 | + $mappedStatement=new TMappedStatement($this->_manager, $statement); |
|
250 | 250 | $this->_manager->addMappedStatement($mappedStatement); |
251 | 251 | } |
252 | 252 | |
@@ -258,15 +258,15 @@ discard block |
||
258 | 258 | */ |
259 | 259 | protected function processSqlStatement($statement, $node) |
260 | 260 | { |
261 | - $commandText = (string)$node; |
|
262 | - if(strlen($extend = $statement->getExtends()) > 0) |
|
261 | + $commandText=(string) $node; |
|
262 | + if(strlen($extend=$statement->getExtends()) > 0) |
|
263 | 263 | { |
264 | - $superNode = $this->getElementByIdValue($this->_document,'*',$extend); |
|
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 | - 'sqlmap_unable_to_find_parent_sql', $extend, $this->_configFile,$node); |
|
269 | + 'sqlmap_unable_to_find_parent_sql', $extend, $this->_configFile, $node); |
|
270 | 270 | } |
271 | 271 | //$commandText = $this->_xmlConfig->replaceProperties($commandText); |
272 | 272 | $statement->initialize($this->_manager); |
@@ -281,27 +281,27 @@ discard block |
||
281 | 281 | */ |
282 | 282 | protected function applyInlineParameterMap($statement, $sqlStatement, $node) |
283 | 283 | { |
284 | - $scope['file'] = $this->_configFile; |
|
285 | - $scope['node'] = $node; |
|
284 | + $scope['file']=$this->_configFile; |
|
285 | + $scope['node']=$node; |
|
286 | 286 | |
287 | - $sqlStatement=preg_replace(self::ESCAPED_INLINE_SYMBOL_REGEXP,self::INLINE_PLACEHOLDER,$sqlStatement); |
|
288 | - if($statement->parameterMap() === null) |
|
287 | + $sqlStatement=preg_replace(self::ESCAPED_INLINE_SYMBOL_REGEXP, self::INLINE_PLACEHOLDER, $sqlStatement); |
|
288 | + if($statement->parameterMap()===null) |
|
289 | 289 | { |
290 | 290 | // Build a Parametermap with the inline parameters. |
291 | 291 | // if they exist. Then delete inline infos from sqltext. |
292 | - $parameterParser = new TInlineParameterMapParser; |
|
293 | - $sqlText = $parameterParser->parse($sqlStatement, $scope); |
|
292 | + $parameterParser=new TInlineParameterMapParser; |
|
293 | + $sqlText=$parameterParser->parse($sqlStatement, $scope); |
|
294 | 294 | if(count($sqlText['parameters']) > 0) |
295 | 295 | { |
296 | - $map = new TParameterMap(); |
|
296 | + $map=new TParameterMap(); |
|
297 | 297 | $map->setID($statement->getID().'-InLineParameterMap'); |
298 | 298 | $statement->setInlineParameterMap($map); |
299 | 299 | foreach($sqlText['parameters'] as $property) |
300 | 300 | $map->addProperty($property); |
301 | 301 | } |
302 | - $sqlStatement = $sqlText['sql']; |
|
302 | + $sqlStatement=$sqlText['sql']; |
|
303 | 303 | } |
304 | - $sqlStatement=preg_replace('/'.self::INLINE_PLACEHOLDER.'/',self::INLINE_SYMBOL,$sqlStatement); |
|
304 | + $sqlStatement=preg_replace('/'.self::INLINE_PLACEHOLDER.'/', self::INLINE_SYMBOL, $sqlStatement); |
|
305 | 305 | |
306 | 306 | $this->prepareSql($statement, $sqlStatement, $node); |
307 | 307 | } |
@@ -313,19 +313,19 @@ discard block |
||
313 | 313 | * @param SimpleXmlElement statement node. |
314 | 314 | * @todo Extend to dynamic sql. |
315 | 315 | */ |
316 | - protected function prepareSql($statement,$sqlStatement, $node) |
|
316 | + protected function prepareSql($statement, $sqlStatement, $node) |
|
317 | 317 | { |
318 | - $simpleDynamic = new TSimpleDynamicParser; |
|
319 | - $sqlStatement=preg_replace(self::ESCAPED_SIMPLE_MARK_REGEXP,self::SIMPLE_PLACEHOLDER,$sqlStatement); |
|
320 | - $dynamics = $simpleDynamic->parse($sqlStatement); |
|
318 | + $simpleDynamic=new TSimpleDynamicParser; |
|
319 | + $sqlStatement=preg_replace(self::ESCAPED_SIMPLE_MARK_REGEXP, self::SIMPLE_PLACEHOLDER, $sqlStatement); |
|
320 | + $dynamics=$simpleDynamic->parse($sqlStatement); |
|
321 | 321 | if(count($dynamics['parameters']) > 0) |
322 | 322 | { |
323 | - $sql = new TSimpleDynamicSql($dynamics['parameters']); |
|
324 | - $sqlStatement = $dynamics['sql']; |
|
323 | + $sql=new TSimpleDynamicSql($dynamics['parameters']); |
|
324 | + $sqlStatement=$dynamics['sql']; |
|
325 | 325 | } |
326 | 326 | else |
327 | - $sql = new TStaticSql(); |
|
328 | - $sqlStatement=preg_replace('/'.self::SIMPLE_PLACEHOLDER.'/',self::SIMPLE_MARK,$sqlStatement); |
|
327 | + $sql=new TStaticSql(); |
|
328 | + $sqlStatement=preg_replace('/'.self::SIMPLE_PLACEHOLDER.'/', self::SIMPLE_MARK, $sqlStatement); |
|
329 | 329 | $sql->buildPreparedStatement($statement, $sqlStatement); |
330 | 330 | $statement->setSqlText($sql); |
331 | 331 | } |
@@ -336,12 +336,12 @@ discard block |
||
336 | 336 | */ |
337 | 337 | protected function loadSelectTag($node) |
338 | 338 | { |
339 | - $select = new TSqlMapSelect; |
|
340 | - $this->setObjectPropFromNode($select,$node); |
|
341 | - $this->processSqlStatement($select,$node); |
|
342 | - $mappedStatement = new TMappedStatement($this->_manager, $select); |
|
339 | + $select=new TSqlMapSelect; |
|
340 | + $this->setObjectPropFromNode($select, $node); |
|
341 | + $this->processSqlStatement($select, $node); |
|
342 | + $mappedStatement=new TMappedStatement($this->_manager, $select); |
|
343 | 343 | if(strlen($select->getCacheModel()) > 0) |
344 | - $mappedStatement = new TCachingStatement($mappedStatement); |
|
344 | + $mappedStatement=new TCachingStatement($mappedStatement); |
|
345 | 345 | |
346 | 346 | $this->_manager->addMappedStatement($mappedStatement); |
347 | 347 | } |
@@ -352,9 +352,9 @@ discard block |
||
352 | 352 | */ |
353 | 353 | protected function loadInsertTag($node) |
354 | 354 | { |
355 | - $insert = $this->createInsertStatement($node); |
|
355 | + $insert=$this->createInsertStatement($node); |
|
356 | 356 | $this->processSqlStatement($insert, $node); |
357 | - $mappedStatement = new TInsertMappedStatement($this->_manager, $insert); |
|
357 | + $mappedStatement=new TInsertMappedStatement($this->_manager, $insert); |
|
358 | 358 | $this->_manager->addMappedStatement($mappedStatement); |
359 | 359 | } |
360 | 360 | |
@@ -365,10 +365,10 @@ discard block |
||
365 | 365 | */ |
366 | 366 | protected function createInsertStatement($node) |
367 | 367 | { |
368 | - $insert = new TSqlMapInsert; |
|
369 | - $this->setObjectPropFromNode($insert,$node); |
|
368 | + $insert=new TSqlMapInsert; |
|
369 | + $this->setObjectPropFromNode($insert, $node); |
|
370 | 370 | if(isset($node->selectKey)) |
371 | - $this->loadSelectKeyTag($insert,$node->selectKey); |
|
371 | + $this->loadSelectKeyTag($insert, $node->selectKey); |
|
372 | 372 | return $insert; |
373 | 373 | } |
374 | 374 | |
@@ -378,13 +378,13 @@ discard block |
||
378 | 378 | */ |
379 | 379 | protected function loadSelectKeyTag($insert, $node) |
380 | 380 | { |
381 | - $selectKey = new TSqlMapSelectKey; |
|
382 | - $this->setObjectPropFromNode($selectKey,$node); |
|
381 | + $selectKey=new TSqlMapSelectKey; |
|
382 | + $this->setObjectPropFromNode($selectKey, $node); |
|
383 | 383 | $selectKey->setID($insert->getID()); |
384 | 384 | $selectKey->setID($insert->getID().'.SelectKey'); |
385 | - $this->processSqlStatement($selectKey,$node); |
|
385 | + $this->processSqlStatement($selectKey, $node); |
|
386 | 386 | $insert->setSelectKey($selectKey); |
387 | - $mappedStatement = new TMappedStatement($this->_manager, $selectKey); |
|
387 | + $mappedStatement=new TMappedStatement($this->_manager, $selectKey); |
|
388 | 388 | $this->_manager->addMappedStatement($mappedStatement); |
389 | 389 | } |
390 | 390 | |
@@ -394,10 +394,10 @@ discard block |
||
394 | 394 | */ |
395 | 395 | protected function loadUpdateTag($node) |
396 | 396 | { |
397 | - $update = new TSqlMapUpdate; |
|
398 | - $this->setObjectPropFromNode($update,$node); |
|
397 | + $update=new TSqlMapUpdate; |
|
398 | + $this->setObjectPropFromNode($update, $node); |
|
399 | 399 | $this->processSqlStatement($update, $node); |
400 | - $mappedStatement = new TUpdateMappedStatement($this->_manager, $update); |
|
400 | + $mappedStatement=new TUpdateMappedStatement($this->_manager, $update); |
|
401 | 401 | $this->_manager->addMappedStatement($mappedStatement); |
402 | 402 | } |
403 | 403 | |
@@ -407,10 +407,10 @@ discard block |
||
407 | 407 | */ |
408 | 408 | protected function loadDeleteTag($node) |
409 | 409 | { |
410 | - $delete = new TSqlMapDelete; |
|
411 | - $this->setObjectPropFromNode($delete,$node); |
|
410 | + $delete=new TSqlMapDelete; |
|
411 | + $this->setObjectPropFromNode($delete, $node); |
|
412 | 412 | $this->processSqlStatement($delete, $node); |
413 | - $mappedStatement = new TDeleteMappedStatement($this->_manager, $delete); |
|
413 | + $mappedStatement=new TDeleteMappedStatement($this->_manager, $delete); |
|
414 | 414 | $this->_manager->addMappedStatement($mappedStatement); |
415 | 415 | } |
416 | 416 | |
@@ -430,35 +430,35 @@ discard block |
||
430 | 430 | */ |
431 | 431 | protected function loadCacheModel($node) |
432 | 432 | { |
433 | - $cacheModel = new TSqlMapCacheModel; |
|
434 | - $properties = array('id','implementation'); |
|
433 | + $cacheModel=new TSqlMapCacheModel; |
|
434 | + $properties=array('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 | - $cache = Prado::createComponent($cacheModel->getImplementationClass(), $cacheModel); |
|
441 | - $this->setObjectPropFromNode($cache,$node,$properties); |
|
440 | + $cache=Prado::createComponent($cacheModel->getImplementationClass(), $cacheModel); |
|
441 | + $this->setObjectPropFromNode($cache, $node, $properties); |
|
442 | 442 | |
443 | 443 | foreach($node->xpath('property') as $propertyNode) |
444 | 444 | { |
445 | - $name = $propertyNode->attributes()->name; |
|
445 | + $name=$propertyNode->attributes()->name; |
|
446 | 446 | if($name===null || $name==='') continue; |
447 | 447 | |
448 | - $value = $propertyNode->attributes()->value; |
|
448 | + $value=$propertyNode->attributes()->value; |
|
449 | 449 | if($value===null || $value==='') continue; |
450 | 450 | |
451 | - if( !TPropertyAccess::has($cache, $name) ) continue; |
|
451 | + if(!TPropertyAccess::has($cache, $name)) continue; |
|
452 | 452 | |
453 | 453 | TPropertyAccess::set($cache, $name, $value); |
454 | 454 | } |
455 | 455 | |
456 | - $this->loadFlushInterval($cacheModel,$node); |
|
456 | + $this->loadFlushInterval($cacheModel, $node); |
|
457 | 457 | |
458 | 458 | $cacheModel->initialize($cache); |
459 | 459 | $this->_manager->addCacheModel($cacheModel); |
460 | 460 | foreach($node->xpath('flushOnExecute') as $flush) |
461 | - $this->loadFlushOnCache($cacheModel,$node,$flush); |
|
461 | + $this->loadFlushOnCache($cacheModel, $node, $flush); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
@@ -468,27 +468,27 @@ discard block |
||
468 | 468 | */ |
469 | 469 | protected function loadFlushInterval($cacheModel, $node) |
470 | 470 | { |
471 | - $flushInterval = $node->xpath('flushInterval'); |
|
472 | - if($flushInterval === null || count($flushInterval) === 0) return; |
|
473 | - $duration = 0; |
|
471 | + $flushInterval=$node->xpath('flushInterval'); |
|
472 | + if($flushInterval===null || count($flushInterval)===0) return; |
|
473 | + $duration=0; |
|
474 | 474 | foreach($flushInterval[0]->attributes() as $name=>$value) |
475 | 475 | { |
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 | } |
@@ -501,15 +501,15 @@ discard block |
||
501 | 501 | * @param SimpleXmlElement parent node. |
502 | 502 | * @param SimpleXmlElement flush node. |
503 | 503 | */ |
504 | - protected function loadFlushOnCache($cacheModel,$parent,$node) |
|
504 | + protected function loadFlushOnCache($cacheModel, $parent, $node) |
|
505 | 505 | { |
506 | - $id = $cacheModel->getID(); |
|
506 | + $id=$cacheModel->getID(); |
|
507 | 507 | if(!isset($this->_FlushOnExecuteStatements[$id])) |
508 | - $this->_FlushOnExecuteStatements[$id] = array(); |
|
508 | + $this->_FlushOnExecuteStatements[$id]=array(); |
|
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 | |
@@ -520,10 +520,10 @@ discard block |
||
520 | 520 | { |
521 | 521 | foreach($this->_FlushOnExecuteStatements as $cacheID => $statementIDs) |
522 | 522 | { |
523 | - $cacheModel = $this->_manager->getCacheModel($cacheID); |
|
523 | + $cacheModel=$this->_manager->getCacheModel($cacheID); |
|
524 | 524 | foreach($statementIDs as $statementID) |
525 | 525 | { |
526 | - $statement = $this->_manager->getMappedStatement($statementID); |
|
526 | + $statement=$this->_manager->getMappedStatement($statementID); |
|
527 | 527 | $cacheModel->registerTriggerStatement($statement); |
528 | 528 | } |
529 | 529 | } |
@@ -322,8 +322,7 @@ |
||
322 | 322 | { |
323 | 323 | $sql = new TSimpleDynamicSql($dynamics['parameters']); |
324 | 324 | $sqlStatement = $dynamics['sql']; |
325 | - } |
|
326 | - else |
|
325 | + } else |
|
327 | 326 | $sql = new TStaticSql(); |
328 | 327 | $sqlStatement=preg_replace('/'.self::SIMPLE_PLACEHOLDER.'/',self::SIMPLE_MARK,$sqlStatement); |
329 | 328 | $sql->buildPreparedStatement($statement, $sqlStatement); |
@@ -116,6 +116,7 @@ |
||
116 | 116 | /** |
117 | 117 | * @param object handler to method calls. |
118 | 118 | * @param object the object to by proxied. |
119 | + * @param TLazyLoadList $handler |
|
119 | 120 | */ |
120 | 121 | public function __construct($handler, $object) |
121 | 122 | { |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function __construct($handler, $object) |
32 | 32 | { |
33 | - $this->_handler = $handler; |
|
34 | - $this->_object = $object; |
|
33 | + $this->_handler=$handler; |
|
34 | + $this->_object=$object; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param array method arguments |
42 | 42 | * @return mixed method return value. |
43 | 43 | */ |
44 | - public function __call($method,$params) |
|
44 | + public function __call($method, $params) |
|
45 | 45 | { |
46 | 46 | if($this->_handler->hasMethod($method)) |
47 | 47 | return $this->_handler->intercept($method, $params); |
@@ -205,6 +205,9 @@ |
||
205 | 205 | return $keyList; |
206 | 206 | } |
207 | 207 | |
208 | + /** |
|
209 | + * @param TList $keyList |
|
210 | + */ |
|
208 | 211 | protected function setKeyList($keyList) |
209 | 212 | { |
210 | 213 | $this->getCache()->set($this->getKeyListId(), $keyList); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | protected function getKeyListId() |
44 | 44 | { |
45 | 45 | $id='keyList'; |
46 | - if ($this->_cacheModel instanceof TSqlMapCacheModel) |
|
46 | + if($this->_cacheModel instanceof TSqlMapCacheModel) |
|
47 | 47 | $id.='_'.$this->_cacheModel->getId(); |
48 | 48 | return $id; |
49 | 49 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | protected function getKeyList() |
55 | 55 | { |
56 | - if (($keyList=$this->getCache()->get($this->getKeyListId()))===false) |
|
56 | + if(($keyList=$this->getCache()->get($this->getKeyListId()))===false) |
|
57 | 57 | { |
58 | 58 | $keyList=new TList(); |
59 | 59 | $this->getCache()->set($this->getKeyListId(), $keyList); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | { |
85 | 85 | $keyList=$this->getKeyList(); |
86 | 86 | $cache=$this->getCache(); |
87 | - foreach ($keyList as $key) |
|
87 | + foreach($keyList as $key) |
|
88 | 88 | { |
89 | 89 | $cache->delete($key); |
90 | 90 | } |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function get($key) |
99 | 99 | { |
100 | - $result = $this->getCache()->get($key); |
|
101 | - if ($result === false) |
|
100 | + $result=$this->getCache()->get($key); |
|
101 | + if($result===false) |
|
102 | 102 | { |
103 | 103 | // if the key has not been found in cache (e.g expired), remove from keylist |
104 | 104 | $keyList=$this->getKeyList(); |
105 | - if ($keyList->contains($key)) |
|
105 | + if($keyList->contains($key)) |
|
106 | 106 | { |
107 | 107 | $keyList->remove($key); |
108 | 108 | $this->setKeyList($keyList); |
109 | 109 | } |
110 | 110 | } |
111 | - return $result === false ? null : $result; |
|
111 | + return $result===false ? null : $result; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | * @param string the key identifying the value to be cached |
117 | 117 | * @param mixed the value to be cached |
118 | 118 | */ |
119 | - public function set($key, $value,$expire=0,$dependency=null) |
|
119 | + public function set($key, $value, $expire=0, $dependency=null) |
|
120 | 120 | { |
121 | - $this->getCache()->set($key, $value, $expire,$dependency); |
|
121 | + $this->getCache()->set($key, $value, $expire, $dependency); |
|
122 | 122 | $keyList=$this->getKeyList(); |
123 | - if (!$keyList->contains($key)) |
|
123 | + if(!$keyList->contains($key)) |
|
124 | 124 | { |
125 | 125 | $keyList->add($key); |
126 | 126 | $this->setKeyList($keyList); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | /** |
139 | 139 | * @throws TSqlMapException not implemented. |
140 | 140 | */ |
141 | - public function add($id,$value,$expire=0,$dependency=null) |
|
141 | + public function add($id, $value, $expire=0, $dependency=null) |
|
142 | 142 | { |
143 | 143 | throw new TSqlMapException('sqlmap_use_set_to_store_cache'); |
144 | 144 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | - * @return TSqlMapper The SqlMap used by this MappedStatement |
|
99 | + * @return TSqlMapManager The SqlMap used by this MappedStatement |
|
100 | 100 | */ |
101 | 101 | public function getManager() |
102 | 102 | { |
@@ -481,6 +481,7 @@ discard block |
||
481 | 481 | * @param IDbConnection database connection |
482 | 482 | * @param mixed insert statement parameter |
483 | 483 | * @param TSqlMapSelectKey select key statement |
484 | + * @param \Prado\Data\SqlMap\Configuration\TSqlMapSelectKey $selectKey |
|
484 | 485 | * @return string last insert ID. |
485 | 486 | */ |
486 | 487 | protected function executeSelectKey($connection, $parameter, $selectKey) |
@@ -581,6 +582,7 @@ discard block |
||
581 | 582 | * @param string result object class name |
582 | 583 | * @param array a result set row retrieved from the database |
583 | 584 | * @param object the result object, will create if necessary. |
585 | + * @param string $resultClass |
|
584 | 586 | * @return object result object filled with data |
585 | 587 | */ |
586 | 588 | protected function fillResultClass($resultClass, $row, $resultObject) |
@@ -603,6 +605,7 @@ discard block |
||
603 | 605 | * Apply the result to a TList or an array. |
604 | 606 | * @param array a result set row retrieved from the database |
605 | 607 | * @param object result object, array or list |
608 | + * @param \ArrayAccess $resultObject |
|
606 | 609 | * @return object result filled with data. |
607 | 610 | */ |
608 | 611 | protected function fillResultArrayList($row, $resultObject) |
@@ -645,6 +648,7 @@ discard block |
||
645 | 648 | * @param string result map name. |
646 | 649 | * @param array a result set row retrieved from the database |
647 | 650 | * @param object result object to fill, will create new instances if required. |
651 | + * @param string $parentGroup |
|
648 | 652 | * @return object result object filled with data. |
649 | 653 | */ |
650 | 654 | protected function fillResultMap($resultMapName, $row, $parentGroup=null, &$resultObject=null) |
@@ -784,6 +788,7 @@ discard block |
||
784 | 788 | * Converts the first array value to scalar value of given type. |
785 | 789 | * @param array list of results |
786 | 790 | * @param string scalar type. |
791 | + * @param string $type |
|
787 | 792 | * @return mixed scalar value. |
788 | 793 | */ |
789 | 794 | protected function getScalarResult($result, $type) |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | /** |
57 | 57 | * @var boolean true when data is mapped to a particular row. |
58 | 58 | */ |
59 | - private $_IsRowDataFound = false; |
|
59 | + private $_IsRowDataFound=false; |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @var TSQLMapObjectCollectionTree group by object collection tree |
@@ -66,17 +66,17 @@ discard block |
||
66 | 66 | /** |
67 | 67 | * @var Post select is to query for list. |
68 | 68 | */ |
69 | - const QUERY_FOR_LIST = 0; |
|
69 | + const QUERY_FOR_LIST=0; |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @var Post select is to query for list. |
73 | 73 | */ |
74 | - const QUERY_FOR_ARRAY = 1; |
|
74 | + const QUERY_FOR_ARRAY=1; |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * @var Post select is to query for object. |
78 | 78 | */ |
79 | - const QUERY_FOR_OBJECT = 2; |
|
79 | + const QUERY_FOR_OBJECT=2; |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * @return string Name used to identify the TMappedStatement amongst the others. |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | protected function initialGroupByResults() |
118 | 118 | { |
119 | - $this->_groupBy = new TSqlMapObjectCollectionTree(); |
|
119 | + $this->_groupBy=new TSqlMapObjectCollectionTree(); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function __construct(TSqlMapManager $sqlMap, TSqlMapStatement $statement) |
128 | 128 | { |
129 | - $this->_manager = $sqlMap; |
|
130 | - $this->_statement = $statement; |
|
131 | - $this->_command = new TPreparedCommand(); |
|
129 | + $this->_manager=$sqlMap; |
|
130 | + $this->_statement=$statement; |
|
131 | + $this->_command=new TPreparedCommand(); |
|
132 | 132 | $this->initialGroupByResults(); |
133 | 133 | } |
134 | 134 | |
@@ -173,10 +173,10 @@ discard block |
||
173 | 173 | */ |
174 | 174 | protected function executeSQLQueryLimit($connection, $command, $max, $skip) |
175 | 175 | { |
176 | - if($max>-1 || $skip > -1) |
|
176 | + if($max > -1 || $skip > -1) |
|
177 | 177 | { |
178 | - $maxStr=$max>0?' LIMIT '.$max:''; |
|
179 | - $skipStr=$skip>0?' OFFSET '.$skip:''; |
|
178 | + $maxStr=$max > 0 ? ' LIMIT '.$max : ''; |
|
179 | + $skipStr=$skip > 0 ? ' OFFSET '.$skip : ''; |
|
180 | 180 | $command->setText($command->getText().$maxStr.$skipStr); |
181 | 181 | } |
182 | 182 | $connection->setActive(true); |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function executeQueryForList($connection, $parameter, $result=null, $skip=-1, $max=-1, $delegate=null) |
215 | 215 | { |
216 | - $sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter,$skip,$max); |
|
216 | + $sql=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter, $skip, $max); |
|
217 | 217 | return $this->runQueryForList($connection, $parameter, $sql, $result, $delegate); |
218 | 218 | } |
219 | 219 | |
@@ -236,17 +236,16 @@ discard block |
||
236 | 236 | public function runQueryForList($connection, $parameter, $sql, $result, $delegate=null) |
237 | 237 | { |
238 | 238 | $registry=$this->getManager()->getTypeHandlers(); |
239 | - $list = $result instanceof \ArrayAccess ? $result : |
|
240 | - $this->_statement->createInstanceOfListClass($registry); |
|
239 | + $list=$result instanceof \ArrayAccess ? $result : $this->_statement->createInstanceOfListClass($registry); |
|
241 | 240 | $connection->setActive(true); |
242 | - $reader = $sql->query(); |
|
241 | + $reader=$sql->query(); |
|
243 | 242 | //$reader = $this->executeSQLQueryLimit($connection, $sql, $max, $skip); |
244 | 243 | if($delegate!==null) |
245 | 244 | { |
246 | 245 | foreach($reader as $row) |
247 | 246 | { |
248 | - $obj = $this->applyResultMap($row); |
|
249 | - $param = new TResultSetListItemParameter($obj, $parameter, $list); |
|
247 | + $obj=$this->applyResultMap($row); |
|
248 | + $param=new TResultSetListItemParameter($obj, $parameter, $list); |
|
250 | 249 | $this->raiseRowDelegate($delegate, $param); |
251 | 250 | } |
252 | 251 | } |
@@ -256,13 +255,13 @@ discard block |
||
256 | 255 | foreach($reader as $row) |
257 | 256 | { |
258 | 257 | // var_dump($row); |
259 | - $list[] = $this->applyResultMap($row); |
|
258 | + $list[]=$this->applyResultMap($row); |
|
260 | 259 | } |
261 | 260 | } |
262 | 261 | |
263 | 262 | if(!$this->_groupBy->isEmpty()) |
264 | 263 | { |
265 | - $list = $this->_groupBy->collect(); |
|
264 | + $list=$this->_groupBy->collect(); |
|
266 | 265 | $this->initialGroupByResults(); |
267 | 266 | } |
268 | 267 | |
@@ -284,9 +283,9 @@ discard block |
||
284 | 283 | * @param callback row delegate handler |
285 | 284 | * @return array An array of object containing the rows keyed by keyProperty. |
286 | 285 | */ |
287 | - public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty=null, $skip=-1, $max=-1, $delegate=null) |
|
286 | + public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty=null, $skip=-1, $max=-1, $delegate=null) |
|
288 | 287 | { |
289 | - $sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter, $skip, $max); |
|
288 | + $sql=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter, $skip, $max); |
|
290 | 289 | return $this->runQueryForMap($connection, $parameter, $sql, $keyProperty, $valueProperty, $delegate); |
291 | 290 | } |
292 | 291 | |
@@ -310,20 +309,19 @@ discard block |
||
310 | 309 | */ |
311 | 310 | public function runQueryForMap($connection, $parameter, $command, $keyProperty, $valueProperty=null, $delegate=null) |
312 | 311 | { |
313 | - $map = array(); |
|
312 | + $map=array(); |
|
314 | 313 | //$recordSet = $this->executeSQLQuery($connection, $sql); |
315 | 314 | $connection->setActive(true); |
316 | - $reader = $command->query(); |
|
315 | + $reader=$command->query(); |
|
317 | 316 | if($delegate!==null) |
318 | 317 | { |
319 | 318 | //while($row = $recordSet->fetchRow()) |
320 | 319 | foreach($reader as $row) |
321 | 320 | { |
322 | - $obj = $this->applyResultMap($row); |
|
323 | - $key = TPropertyAccess::get($obj, $keyProperty); |
|
324 | - $value = ($valueProperty===null) ? $obj : |
|
325 | - TPropertyAccess::get($obj, $valueProperty); |
|
326 | - $param = new TResultSetMapItemParameter($key, $value, $parameter, $map); |
|
321 | + $obj=$this->applyResultMap($row); |
|
322 | + $key=TPropertyAccess::get($obj, $keyProperty); |
|
323 | + $value=($valueProperty===null) ? $obj : TPropertyAccess::get($obj, $valueProperty); |
|
324 | + $param=new TResultSetMapItemParameter($key, $value, $parameter, $map); |
|
327 | 325 | $this->raiseRowDelegate($delegate, $param); |
328 | 326 | } |
329 | 327 | } |
@@ -332,10 +330,9 @@ discard block |
||
332 | 330 | //while($row = $recordSet->fetchRow()) |
333 | 331 | foreach($reader as $row) |
334 | 332 | { |
335 | - $obj = $this->applyResultMap($row); |
|
336 | - $key = TPropertyAccess::get($obj, $keyProperty); |
|
337 | - $map[$key] = ($valueProperty===null) ? $obj : |
|
338 | - TPropertyAccess::get($obj, $valueProperty); |
|
333 | + $obj=$this->applyResultMap($row); |
|
334 | + $key=TPropertyAccess::get($obj, $keyProperty); |
|
335 | + $map[$key]=($valueProperty===null) ? $obj : TPropertyAccess::get($obj, $valueProperty); |
|
339 | 336 | } |
340 | 337 | } |
341 | 338 | $this->onExecuteQuery($command); |
@@ -352,22 +349,22 @@ discard block |
||
352 | 349 | { |
353 | 350 | if(is_string($handler)) |
354 | 351 | { |
355 | - call_user_func($handler,$this,$param); |
|
352 | + call_user_func($handler, $this, $param); |
|
356 | 353 | } |
357 | - else if(is_callable($handler,true)) |
|
354 | + else if(is_callable($handler, true)) |
|
358 | 355 | { |
359 | 356 | // an array: 0 - object, 1 - method name/path |
360 | - list($object,$method)=$handler; |
|
357 | + list($object, $method)=$handler; |
|
361 | 358 | if(is_string($object)) // static method call |
362 | - call_user_func($handler,$this,$param); |
|
359 | + call_user_func($handler, $this, $param); |
|
363 | 360 | else |
364 | 361 | { |
365 | - if(($pos=strrpos($method,'.'))!==false) |
|
362 | + if(($pos=strrpos($method, '.'))!==false) |
|
366 | 363 | { |
367 | - $object=$this->getSubProperty(substr($method,0,$pos)); |
|
368 | - $method=substr($method,$pos+1); |
|
364 | + $object=$this->getSubProperty(substr($method, 0, $pos)); |
|
365 | + $method=substr($method, $pos + 1); |
|
369 | 366 | } |
370 | - $object->$method($this,$param); |
|
367 | + $object->$method($this, $param); |
|
371 | 368 | } |
372 | 369 | } |
373 | 370 | else |
@@ -384,7 +381,7 @@ discard block |
||
384 | 381 | */ |
385 | 382 | public function executeQueryForObject($connection, $parameter, $result=null) |
386 | 383 | { |
387 | - $sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
384 | + $sql=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
388 | 385 | return $this->runQueryForObject($connection, $sql, $result); |
389 | 386 | } |
390 | 387 | |
@@ -403,16 +400,16 @@ discard block |
||
403 | 400 | */ |
404 | 401 | public function runQueryForObject($connection, $command, &$result) |
405 | 402 | { |
406 | - $object = null; |
|
403 | + $object=null; |
|
407 | 404 | $connection->setActive(true); |
408 | 405 | foreach($command->query() as $row) |
409 | - $object = $this->applyResultMap($row, $result); |
|
406 | + $object=$this->applyResultMap($row, $result); |
|
410 | 407 | |
411 | 408 | if(!$this->_groupBy->isEmpty()) |
412 | 409 | { |
413 | - $list = $this->_groupBy->collect(); |
|
410 | + $list=$this->_groupBy->collect(); |
|
414 | 411 | $this->initialGroupByResults(); |
415 | - $object = $list[0]; |
|
412 | + $object=$list[0]; |
|
416 | 413 | } |
417 | 414 | |
418 | 415 | $this->executePostSelect($connection); |
@@ -430,14 +427,14 @@ discard block |
||
430 | 427 | */ |
431 | 428 | public function executeInsert($connection, $parameter) |
432 | 429 | { |
433 | - $generatedKey = $this->getPreGeneratedSelectKey($connection, $parameter); |
|
430 | + $generatedKey=$this->getPreGeneratedSelectKey($connection, $parameter); |
|
434 | 431 | |
435 | - $command = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
432 | + $command=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
436 | 433 | // var_dump($command,$parameter); |
437 | - $result = $command->execute(); |
|
434 | + $result=$command->execute(); |
|
438 | 435 | |
439 | 436 | if($generatedKey===null) |
440 | - $generatedKey = $this->getPostGeneratedSelectKey($connection, $parameter); |
|
437 | + $generatedKey=$this->getPostGeneratedSelectKey($connection, $parameter); |
|
441 | 438 | |
442 | 439 | $this->executePostSelect($connection); |
443 | 440 | $this->onExecuteQuery($command); |
@@ -454,7 +451,7 @@ discard block |
||
454 | 451 | { |
455 | 452 | if($this->_statement instanceof TSqlMapInsert) |
456 | 453 | { |
457 | - $selectKey = $this->_statement->getSelectKey(); |
|
454 | + $selectKey=$this->_statement->getSelectKey(); |
|
458 | 455 | if(($selectKey!==null) && !$selectKey->getIsAfter()) |
459 | 456 | return $this->executeSelectKey($connection, $parameter, $selectKey); |
460 | 457 | } |
@@ -470,7 +467,7 @@ discard block |
||
470 | 467 | { |
471 | 468 | if($this->_statement instanceof TSqlMapInsert) |
472 | 469 | { |
473 | - $selectKey = $this->_statement->getSelectKey(); |
|
470 | + $selectKey=$this->_statement->getSelectKey(); |
|
474 | 471 | if(($selectKey!==null) && $selectKey->getIsAfter()) |
475 | 472 | return $this->executeSelectKey($connection, $parameter, $selectKey); |
476 | 473 | } |
@@ -485,10 +482,10 @@ discard block |
||
485 | 482 | */ |
486 | 483 | protected function executeSelectKey($connection, $parameter, $selectKey) |
487 | 484 | { |
488 | - $mappedStatement = $this->getManager()->getMappedStatement($selectKey->getID()); |
|
489 | - $generatedKey = $mappedStatement->executeQueryForObject( |
|
485 | + $mappedStatement=$this->getManager()->getMappedStatement($selectKey->getID()); |
|
486 | + $generatedKey=$mappedStatement->executeQueryForObject( |
|
490 | 487 | $connection, $parameter, null); |
491 | - if(strlen($prop = $selectKey->getProperty()) > 0) |
|
488 | + if(strlen($prop=$selectKey->getProperty()) > 0) |
|
492 | 489 | TPropertyAccess::set($parameter, $prop, $generatedKey); |
493 | 490 | return $generatedKey; |
494 | 491 | } |
@@ -502,8 +499,8 @@ discard block |
||
502 | 499 | */ |
503 | 500 | public function executeUpdate($connection, $parameter) |
504 | 501 | { |
505 | - $sql = $this->_command->create($this->getManager(),$connection, $this->_statement, $parameter); |
|
506 | - $affectedRows = $sql->execute(); |
|
502 | + $sql=$this->_command->create($this->getManager(), $connection, $this->_statement, $parameter); |
|
503 | + $affectedRows=$sql->execute(); |
|
507 | 504 | //$this->executeSQLQuery($connection, $sql); |
508 | 505 | $this->executePostSelect($connection); |
509 | 506 | $this->onExecuteQuery($sql); |
@@ -518,24 +515,24 @@ discard block |
||
518 | 515 | { |
519 | 516 | while(count($this->_selectQueue)) |
520 | 517 | { |
521 | - $postSelect = array_shift($this->_selectQueue); |
|
522 | - $method = $postSelect->getMethod(); |
|
523 | - $statement = $postSelect->getStatement(); |
|
524 | - $property = $postSelect->getResultProperty()->getProperty(); |
|
525 | - $keys = $postSelect->getKeys(); |
|
526 | - $resultObject = $postSelect->getResultObject(); |
|
527 | - |
|
528 | - if($method == self::QUERY_FOR_LIST || $method == self::QUERY_FOR_ARRAY) |
|
518 | + $postSelect=array_shift($this->_selectQueue); |
|
519 | + $method=$postSelect->getMethod(); |
|
520 | + $statement=$postSelect->getStatement(); |
|
521 | + $property=$postSelect->getResultProperty()->getProperty(); |
|
522 | + $keys=$postSelect->getKeys(); |
|
523 | + $resultObject=$postSelect->getResultObject(); |
|
524 | + |
|
525 | + if($method==self::QUERY_FOR_LIST || $method==self::QUERY_FOR_ARRAY) |
|
529 | 526 | { |
530 | - $values = $statement->executeQueryForList($connection, $keys, null); |
|
527 | + $values=$statement->executeQueryForList($connection, $keys, null); |
|
531 | 528 | |
532 | - if($method == self::QUERY_FOR_ARRAY) |
|
533 | - $values = $values->toArray(); |
|
529 | + if($method==self::QUERY_FOR_ARRAY) |
|
530 | + $values=$values->toArray(); |
|
534 | 531 | TPropertyAccess::set($resultObject, $property, $values); |
535 | 532 | } |
536 | - else if($method == self::QUERY_FOR_OBJECT) |
|
533 | + else if($method==self::QUERY_FOR_OBJECT) |
|
537 | 534 | { |
538 | - $value = $statement->executeQueryForObject($connection, $keys, null); |
|
535 | + $value=$statement->executeQueryForObject($connection, $keys, null); |
|
539 | 536 | TPropertyAccess::set($resultObject, $property, $value); |
540 | 537 | } |
541 | 538 | } |
@@ -558,21 +555,21 @@ discard block |
||
558 | 555 | */ |
559 | 556 | protected function applyResultMap($row, &$resultObject=null) |
560 | 557 | { |
561 | - if($row === false) return null; |
|
558 | + if($row===false) return null; |
|
562 | 559 | |
563 | - $resultMapName = $this->_statement->getResultMap(); |
|
564 | - $resultClass = $this->_statement->getResultClass(); |
|
560 | + $resultMapName=$this->_statement->getResultMap(); |
|
561 | + $resultClass=$this->_statement->getResultClass(); |
|
565 | 562 | |
566 | 563 | $obj=null; |
567 | 564 | if($this->getManager()->getResultMaps()->contains($resultMapName)) |
568 | - $obj = $this->fillResultMap($resultMapName, $row, null, $resultObject); |
|
565 | + $obj=$this->fillResultMap($resultMapName, $row, null, $resultObject); |
|
569 | 566 | else if(strlen($resultClass) > 0) |
570 | - $obj = $this->fillResultClass($resultClass, $row, $resultObject); |
|
567 | + $obj=$this->fillResultClass($resultClass, $row, $resultObject); |
|
571 | 568 | else |
572 | - $obj = $this->fillDefaultResultMap(null, $row, $resultObject); |
|
573 | - if(class_exists('TActiveRecord',false) && $obj instanceof TActiveRecord) |
|
569 | + $obj=$this->fillDefaultResultMap(null, $row, $resultObject); |
|
570 | + if(class_exists('TActiveRecord', false) && $obj instanceof TActiveRecord) |
|
574 | 571 | //Create a new clean active record. |
575 | - $obj=TActiveRecord::createRecord(get_class($obj),$obj); |
|
572 | + $obj=TActiveRecord::createRecord(get_class($obj), $obj); |
|
576 | 573 | return $obj; |
577 | 574 | } |
578 | 575 | |
@@ -587,8 +584,8 @@ discard block |
||
587 | 584 | { |
588 | 585 | if($resultObject===null) |
589 | 586 | { |
590 | - $registry = $this->getManager()->getTypeHandlers(); |
|
591 | - $resultObject = $this->_statement->createInstanceOfResultClass($registry,$row); |
|
587 | + $registry=$this->getManager()->getTypeHandlers(); |
|
588 | + $resultObject=$this->_statement->createInstanceOfResultClass($registry, $row); |
|
592 | 589 | } |
593 | 590 | |
594 | 591 | if($resultObject instanceOf \ArrayAccess) |
@@ -609,10 +606,10 @@ discard block |
||
609 | 606 | { |
610 | 607 | if($resultObject instanceof TList) |
611 | 608 | foreach($row as $v) |
612 | - $resultObject[] = $v; |
|
609 | + $resultObject[]=$v; |
|
613 | 610 | else |
614 | 611 | foreach($row as $k => $v) |
615 | - $resultObject[$k] = $v; |
|
612 | + $resultObject[$k]=$v; |
|
616 | 613 | return $resultObject; |
617 | 614 | } |
618 | 615 | |
@@ -624,18 +621,18 @@ discard block |
||
624 | 621 | */ |
625 | 622 | protected function fillResultObjectProperty($row, $resultObject) |
626 | 623 | { |
627 | - $index = 0; |
|
624 | + $index=0; |
|
628 | 625 | $registry=$this->getManager()->getTypeHandlers(); |
629 | 626 | foreach($row as $k=>$v) |
630 | 627 | { |
631 | - $property = new TResultProperty; |
|
628 | + $property=new TResultProperty; |
|
632 | 629 | if(is_string($k) && strlen($k) > 0) |
633 | 630 | $property->setColumn($k); |
634 | 631 | $property->setColumnIndex(++$index); |
635 | - $type = gettype(TPropertyAccess::get($resultObject,$k)); |
|
632 | + $type=gettype(TPropertyAccess::get($resultObject, $k)); |
|
636 | 633 | $property->setType($type); |
637 | - $value = $property->getPropertyValue($registry,$row); |
|
638 | - TPropertyAccess::set($resultObject, $k,$value); |
|
634 | + $value=$property->getPropertyValue($registry, $row); |
|
635 | + TPropertyAccess::set($resultObject, $k, $value); |
|
639 | 636 | } |
640 | 637 | return $resultObject; |
641 | 638 | } |
@@ -649,12 +646,12 @@ discard block |
||
649 | 646 | */ |
650 | 647 | protected function fillResultMap($resultMapName, $row, $parentGroup=null, &$resultObject=null) |
651 | 648 | { |
652 | - $resultMap = $this->getManager()->getResultMap($resultMapName); |
|
653 | - $registry = $this->getManager()->getTypeHandlers(); |
|
654 | - $resultMap = $resultMap->resolveSubMap($registry,$row); |
|
649 | + $resultMap=$this->getManager()->getResultMap($resultMapName); |
|
650 | + $registry=$this->getManager()->getTypeHandlers(); |
|
651 | + $resultMap=$resultMap->resolveSubMap($registry, $row); |
|
655 | 652 | |
656 | 653 | if($resultObject===null) |
657 | - $resultObject = $resultMap->createInstanceOfResult($registry); |
|
654 | + $resultObject=$resultMap->createInstanceOfResult($registry); |
|
658 | 655 | |
659 | 656 | if(is_object($resultObject)) |
660 | 657 | { |
@@ -666,7 +663,7 @@ discard block |
||
666 | 663 | } |
667 | 664 | else |
668 | 665 | { |
669 | - $resultObject = $this->fillDefaultResultMap($resultMap, $row, $resultObject); |
|
666 | + $resultObject=$this->fillDefaultResultMap($resultMap, $row, $resultObject); |
|
670 | 667 | } |
671 | 668 | return $resultObject; |
672 | 669 | } |
@@ -681,11 +678,11 @@ discard block |
||
681 | 678 | */ |
682 | 679 | protected function addResultMapGroupBy($resultMap, $row, $parent, &$resultObject) |
683 | 680 | { |
684 | - $group = $this->getResultMapGroupKey($resultMap, $row); |
|
681 | + $group=$this->getResultMapGroupKey($resultMap, $row); |
|
685 | 682 | |
686 | 683 | if(empty($parent)) |
687 | 684 | { |
688 | - $rootObject = array('object'=>$resultObject, 'property' => null); |
|
685 | + $rootObject=array('object'=>$resultObject, 'property' => null); |
|
689 | 686 | $this->_groupBy->add(null, $group, $rootObject); |
690 | 687 | } |
691 | 688 | |
@@ -693,23 +690,23 @@ discard block |
||
693 | 690 | { |
694 | 691 | //set properties. |
695 | 692 | $this->setObjectProperty($resultMap, $property, $row, $resultObject); |
696 | - $nested = $property->getResultMapping(); |
|
693 | + $nested=$property->getResultMapping(); |
|
697 | 694 | |
698 | 695 | //nested property |
699 | 696 | if($this->getManager()->getResultMaps()->contains($nested)) |
700 | 697 | { |
701 | - $nestedMap = $this->getManager()->getResultMap($nested); |
|
702 | - $groupKey = $this->getResultMapGroupKey($nestedMap, $row); |
|
698 | + $nestedMap=$this->getManager()->getResultMap($nested); |
|
699 | + $groupKey=$this->getResultMapGroupKey($nestedMap, $row); |
|
703 | 700 | |
704 | 701 | //add the node reference first |
705 | 702 | if(empty($parent)) |
706 | 703 | $this->_groupBy->add($group, $groupKey, ''); |
707 | 704 | |
708 | 705 | //get the nested result mapping value |
709 | - $value = $this->fillResultMap($nested, $row, $groupKey); |
|
706 | + $value=$this->fillResultMap($nested, $row, $groupKey); |
|
710 | 707 | |
711 | 708 | //add it to the object tree graph |
712 | - $groupObject = array('object'=>$value, 'property' => $property->getProperty()); |
|
709 | + $groupObject=array('object'=>$value, 'property' => $property->getProperty()); |
|
713 | 710 | if(empty($parent)) |
714 | 711 | $this->_groupBy->add($group, $groupKey, $groupObject); |
715 | 712 | else |
@@ -727,7 +724,7 @@ discard block |
||
727 | 724 | */ |
728 | 725 | protected function getResultMapGroupKey($resultMap, $row) |
729 | 726 | { |
730 | - $groupBy = $resultMap->getGroupBy(); |
|
727 | + $groupBy=$resultMap->getGroupBy(); |
|
731 | 728 | if(isset($row[$groupBy])) |
732 | 729 | return $resultMap->getID().$row[$groupBy]; |
733 | 730 | else |
@@ -748,12 +745,12 @@ discard block |
||
748 | 745 | $resultObject=''; |
749 | 746 | |
750 | 747 | if($resultMap!==null) |
751 | - $result = $this->fillArrayResultMap($resultMap, $row, $resultObject); |
|
748 | + $result=$this->fillArrayResultMap($resultMap, $row, $resultObject); |
|
752 | 749 | else |
753 | - $result = $row; |
|
750 | + $result=$row; |
|
754 | 751 | |
755 | 752 | //if scalar result types |
756 | - if(count($result) == 1 && ($type = gettype($resultObject))!= 'array') |
|
753 | + if(count($result)==1 && ($type=gettype($resultObject))!='array') |
|
757 | 754 | return $this->getScalarResult($result, $type); |
758 | 755 | else |
759 | 756 | return $result; |
@@ -768,14 +765,14 @@ discard block |
||
768 | 765 | */ |
769 | 766 | protected function fillArrayResultMap($resultMap, $row, $resultObject) |
770 | 767 | { |
771 | - $result = array(); |
|
768 | + $result=array(); |
|
772 | 769 | $registry=$this->getManager()->getTypeHandlers(); |
773 | 770 | foreach($resultMap->getColumns() as $column) |
774 | 771 | { |
775 | 772 | if(($column->getType()===null) |
776 | 773 | && ($resultObject!==null) && !is_object($resultObject)) |
777 | 774 | $column->setType(gettype($resultObject)); |
778 | - $result[$column->getProperty()] = $column->getPropertyValue($registry,$row); |
|
775 | + $result[$column->getProperty()]=$column->getPropertyValue($registry, $row); |
|
779 | 776 | } |
780 | 777 | return $result; |
781 | 778 | } |
@@ -788,7 +785,7 @@ discard block |
||
788 | 785 | */ |
789 | 786 | protected function getScalarResult($result, $type) |
790 | 787 | { |
791 | - $scalar = array_shift($result); |
|
788 | + $scalar=array_shift($result); |
|
792 | 789 | settype($scalar, $type); |
793 | 790 | return $scalar; |
794 | 791 | } |
@@ -802,23 +799,23 @@ discard block |
||
802 | 799 | */ |
803 | 800 | protected function setObjectProperty($resultMap, $property, $row, &$resultObject) |
804 | 801 | { |
805 | - $select = $property->getSelect(); |
|
806 | - $key = $property->getProperty(); |
|
807 | - $nested = $property->getNestedResultMap(); |
|
802 | + $select=$property->getSelect(); |
|
803 | + $key=$property->getProperty(); |
|
804 | + $nested=$property->getNestedResultMap(); |
|
808 | 805 | $registry=$this->getManager()->getTypeHandlers(); |
809 | - if($key === '') |
|
806 | + if($key==='') |
|
810 | 807 | { |
811 | - $resultObject = $property->getPropertyValue($registry,$row); |
|
808 | + $resultObject=$property->getPropertyValue($registry, $row); |
|
812 | 809 | } |
813 | - else if(strlen($select) == 0 && ($nested===null)) |
|
810 | + else if(strlen($select)==0 && ($nested===null)) |
|
814 | 811 | { |
815 | - $value = $property->getPropertyValue($registry,$row); |
|
812 | + $value=$property->getPropertyValue($registry, $row); |
|
816 | 813 | |
817 | - $this->_IsRowDataFound = $this->_IsRowDataFound || ($value != null); |
|
814 | + $this->_IsRowDataFound=$this->_IsRowDataFound || ($value!=null); |
|
818 | 815 | if(is_array($resultObject) || is_object($resultObject)) |
819 | 816 | TPropertyAccess::set($resultObject, $key, $value); |
820 | 817 | else |
821 | - $resultObject = $value; |
|
818 | + $resultObject=$value; |
|
822 | 819 | } |
823 | 820 | else if($nested!==null) |
824 | 821 | { |
@@ -831,9 +828,9 @@ discard block |
||
831 | 828 | } |
832 | 829 | else |
833 | 830 | { |
834 | - $obj = $nested->createInstanceOfResult($this->getManager()->getTypeHandlers()); |
|
835 | - if($this->fillPropertyWithResultMap($nested, $row, $obj) == false) |
|
836 | - $obj = null; |
|
831 | + $obj=$nested->createInstanceOfResult($this->getManager()->getTypeHandlers()); |
|
832 | + if($this->fillPropertyWithResultMap($nested, $row, $obj)==false) |
|
833 | + $obj=null; |
|
837 | 834 | TPropertyAccess::set($resultObject, $key, $obj); |
838 | 835 | } |
839 | 836 | } |
@@ -853,9 +850,9 @@ discard block |
||
853 | 850 | */ |
854 | 851 | protected function enquequePostSelect($select, $resultMap, $property, $row, $resultObject) |
855 | 852 | { |
856 | - $statement = $this->getManager()->getMappedStatement($select); |
|
857 | - $key = $this->getPostSelectKeys($resultMap, $property, $row); |
|
858 | - $postSelect = new TPostSelectBinding; |
|
853 | + $statement=$this->getManager()->getMappedStatement($select); |
|
854 | + $key=$this->getPostSelectKeys($resultMap, $property, $row); |
|
855 | + $postSelect=new TPostSelectBinding; |
|
859 | 856 | $postSelect->setStatement($statement); |
860 | 857 | $postSelect->setResultObject($resultObject); |
861 | 858 | $postSelect->setResultProperty($property); |
@@ -863,10 +860,10 @@ discard block |
||
863 | 860 | |
864 | 861 | if($property->instanceOfListType($resultObject)) |
865 | 862 | { |
866 | - $values = null; |
|
863 | + $values=null; |
|
867 | 864 | if($property->getLazyLoad()) |
868 | 865 | { |
869 | - $values = TLazyLoadList::newInstance($statement, $key, |
|
866 | + $values=TLazyLoadList::newInstance($statement, $key, |
|
870 | 867 | $resultObject, $property->getProperty()); |
871 | 868 | TPropertyAccess::set($resultObject, $property->getProperty(), $values); |
872 | 869 | } |
@@ -879,7 +876,7 @@ discard block |
||
879 | 876 | $postSelect->setMethod(self::QUERY_FOR_OBJECT); |
880 | 877 | |
881 | 878 | if(!$property->getLazyLoad()) |
882 | - $this->_selectQueue[] = $postSelect; |
|
879 | + $this->_selectQueue[]=$postSelect; |
|
883 | 880 | } |
884 | 881 | |
885 | 882 | /** |
@@ -889,23 +886,23 @@ discard block |
||
889 | 886 | * @param array current row data. |
890 | 887 | * @return array list of primary key values. |
891 | 888 | */ |
892 | - protected function getPostSelectKeys($resultMap, $property,$row) |
|
889 | + protected function getPostSelectKeys($resultMap, $property, $row) |
|
893 | 890 | { |
894 | - $value = $property->getColumn(); |
|
895 | - if(is_int(strpos($value.',',0)) || is_int(strpos($value, '=',0))) |
|
891 | + $value=$property->getColumn(); |
|
892 | + if(is_int(strpos($value.',', 0)) || is_int(strpos($value, '=', 0))) |
|
896 | 893 | { |
897 | - $keys = array(); |
|
894 | + $keys=array(); |
|
898 | 895 | foreach(explode(',', $value) as $entry) |
899 | 896 | { |
900 | - $pair =explode('=',$entry); |
|
901 | - $keys[trim($pair[0])] = $row[trim($pair[1])]; |
|
897 | + $pair=explode('=', $entry); |
|
898 | + $keys[trim($pair[0])]=$row[trim($pair[1])]; |
|
902 | 899 | } |
903 | 900 | return $keys; |
904 | 901 | } |
905 | 902 | else |
906 | 903 | { |
907 | 904 | $registry=$this->getManager()->getTypeHandlers(); |
908 | - return $property->getPropertyValue($registry,$row); |
|
905 | + return $property->getPropertyValue($registry, $row); |
|
909 | 906 | } |
910 | 907 | } |
911 | 908 | |
@@ -918,28 +915,28 @@ discard block |
||
918 | 915 | */ |
919 | 916 | protected function fillPropertyWithResultMap($resultMap, $row, &$resultObject) |
920 | 917 | { |
921 | - $dataFound = false; |
|
918 | + $dataFound=false; |
|
922 | 919 | foreach($resultMap->getColumns() as $property) |
923 | 920 | { |
924 | - $this->_IsRowDataFound = false; |
|
921 | + $this->_IsRowDataFound=false; |
|
925 | 922 | $this->setObjectProperty($resultMap, $property, $row, $resultObject); |
926 | - $dataFound = $dataFound || $this->_IsRowDataFound; |
|
923 | + $dataFound=$dataFound || $this->_IsRowDataFound; |
|
927 | 924 | } |
928 | - $this->_IsRowDataFound = $dataFound; |
|
925 | + $this->_IsRowDataFound=$dataFound; |
|
929 | 926 | return $dataFound; |
930 | 927 | } |
931 | 928 | |
932 | 929 | public function __wakeup() |
933 | 930 | { |
934 | - if (is_null($this->_selectQueue)) $this->_selectQueue = array(); |
|
931 | + if(is_null($this->_selectQueue)) $this->_selectQueue=array(); |
|
935 | 932 | } |
936 | 933 | |
937 | 934 | public function __sleep() |
938 | 935 | { |
939 | - $exprops = array(); $cn = __CLASS__; |
|
940 | - if (!count($this->_selectQueue)) $exprops[] = "\0$cn\0_selectQueue"; |
|
941 | - if (is_null($this->_groupBy)) $exprops[] = "\0$cn\0_groupBy"; |
|
942 | - if (!$this->_IsRowDataFound) $exprops[] = "\0$cn\0_IsRowDataFound"; |
|
943 | - return array_diff(parent::__sleep(),$exprops); |
|
936 | + $exprops=array(); $cn=__CLASS__; |
|
937 | + if(!count($this->_selectQueue)) $exprops[]="\0$cn\0_selectQueue"; |
|
938 | + if(is_null($this->_groupBy)) $exprops[]="\0$cn\0_groupBy"; |
|
939 | + if(!$this->_IsRowDataFound) $exprops[]="\0$cn\0_IsRowDataFound"; |
|
940 | + return array_diff(parent::__sleep(), $exprops); |
|
944 | 941 | } |
945 | 942 | } |
946 | 943 | \ No newline at end of file |
@@ -249,8 +249,7 @@ discard block |
||
249 | 249 | $param = new TResultSetListItemParameter($obj, $parameter, $list); |
250 | 250 | $this->raiseRowDelegate($delegate, $param); |
251 | 251 | } |
252 | - } |
|
253 | - else |
|
252 | + } else |
|
254 | 253 | { |
255 | 254 | //var_dump($sql,$parameter); |
256 | 255 | foreach($reader as $row) |
@@ -326,8 +325,7 @@ discard block |
||
326 | 325 | $param = new TResultSetMapItemParameter($key, $value, $parameter, $map); |
327 | 326 | $this->raiseRowDelegate($delegate, $param); |
328 | 327 | } |
329 | - } |
|
330 | - else |
|
328 | + } else |
|
331 | 329 | { |
332 | 330 | //while($row = $recordSet->fetchRow()) |
333 | 331 | foreach($reader as $row) |
@@ -353,8 +351,7 @@ discard block |
||
353 | 351 | if(is_string($handler)) |
354 | 352 | { |
355 | 353 | call_user_func($handler,$this,$param); |
356 | - } |
|
357 | - else if(is_callable($handler,true)) |
|
354 | + } else if(is_callable($handler,true)) |
|
358 | 355 | { |
359 | 356 | // an array: 0 - object, 1 - method name/path |
360 | 357 | list($object,$method)=$handler; |
@@ -369,8 +366,7 @@ discard block |
||
369 | 366 | } |
370 | 367 | $object->$method($this,$param); |
371 | 368 | } |
372 | - } |
|
373 | - else |
|
369 | + } else |
|
374 | 370 | throw new TInvalidDataValueException('sqlmap_invalid_delegate', $this->getID(), $handler); |
375 | 371 | } |
376 | 372 | |
@@ -532,8 +528,7 @@ discard block |
||
532 | 528 | if($method == self::QUERY_FOR_ARRAY) |
533 | 529 | $values = $values->toArray(); |
534 | 530 | TPropertyAccess::set($resultObject, $property, $values); |
535 | - } |
|
536 | - else if($method == self::QUERY_FOR_OBJECT) |
|
531 | + } else if($method == self::QUERY_FOR_OBJECT) |
|
537 | 532 | { |
538 | 533 | $value = $statement->executeQueryForObject($connection, $keys, null); |
539 | 534 | TPropertyAccess::set($resultObject, $property, $value); |
@@ -663,8 +658,7 @@ discard block |
||
663 | 658 | else |
664 | 659 | foreach($resultMap->getColumns() as $property) |
665 | 660 | $this->setObjectProperty($resultMap, $property, $row, $resultObject); |
666 | - } |
|
667 | - else |
|
661 | + } else |
|
668 | 662 | { |
669 | 663 | $resultObject = $this->fillDefaultResultMap($resultMap, $row, $resultObject); |
670 | 664 | } |
@@ -809,8 +803,7 @@ discard block |
||
809 | 803 | if($key === '') |
810 | 804 | { |
811 | 805 | $resultObject = $property->getPropertyValue($registry,$row); |
812 | - } |
|
813 | - else if(strlen($select) == 0 && ($nested===null)) |
|
806 | + } else if(strlen($select) == 0 && ($nested===null)) |
|
814 | 807 | { |
815 | 808 | $value = $property->getPropertyValue($registry,$row); |
816 | 809 | |
@@ -819,8 +812,7 @@ discard block |
||
819 | 812 | TPropertyAccess::set($resultObject, $key, $value); |
820 | 813 | else |
821 | 814 | $resultObject = $value; |
822 | - } |
|
823 | - else if($nested!==null) |
|
815 | + } else if($nested!==null) |
|
824 | 816 | { |
825 | 817 | if($property->instanceOfListType($resultObject) || $property->instanceOfArrayType($resultObject)) |
826 | 818 | { |
@@ -828,16 +820,14 @@ discard block |
||
828 | 820 | throw new TSqlMapExecutionException( |
829 | 821 | 'sqlmap_non_groupby_array_list_type', $resultMap->getID(), |
830 | 822 | get_class($resultObject), $key); |
831 | - } |
|
832 | - else |
|
823 | + } else |
|
833 | 824 | { |
834 | 825 | $obj = $nested->createInstanceOfResult($this->getManager()->getTypeHandlers()); |
835 | 826 | if($this->fillPropertyWithResultMap($nested, $row, $obj) == false) |
836 | 827 | $obj = null; |
837 | 828 | TPropertyAccess::set($resultObject, $key, $obj); |
838 | 829 | } |
839 | - } |
|
840 | - else //'select' ResultProperty |
|
830 | + } else //'select' ResultProperty |
|
841 | 831 | { |
842 | 832 | $this->enquequePostSelect($select, $resultMap, $property, $row, $resultObject); |
843 | 833 | } |
@@ -869,11 +859,9 @@ discard block |
||
869 | 859 | $values = TLazyLoadList::newInstance($statement, $key, |
870 | 860 | $resultObject, $property->getProperty()); |
871 | 861 | TPropertyAccess::set($resultObject, $property->getProperty(), $values); |
872 | - } |
|
873 | - else |
|
862 | + } else |
|
874 | 863 | $postSelect->setMethod(self::QUERY_FOR_LIST); |
875 | - } |
|
876 | - else if($property->instanceOfArrayType($resultObject)) |
|
864 | + } else if($property->instanceOfArrayType($resultObject)) |
|
877 | 865 | $postSelect->setMethod(self::QUERY_FOR_ARRAY); |
878 | 866 | else |
879 | 867 | $postSelect->setMethod(self::QUERY_FOR_OBJECT); |
@@ -901,8 +889,7 @@ discard block |
||
901 | 889 | $keys[trim($pair[0])] = $row[trim($pair[1])]; |
902 | 890 | } |
903 | 891 | return $keys; |
904 | - } |
|
905 | - else |
|
892 | + } else |
|
906 | 893 | { |
907 | 894 | $registry=$this->getManager()->getTypeHandlers(); |
908 | 895 | return $property->getPropertyValue($registry,$row); |
@@ -39,5 +39,9 @@ |
||
39 | 39 | public function setKeys($value){ $this->_keys = $value; } |
40 | 40 | |
41 | 41 | public function getMethod(){ return $this->_method; } |
42 | + |
|
43 | + /** |
|
44 | + * @param integer $value |
|
45 | + */ |
|
42 | 46 | public function setMethod($value){ $this->_method = $value; } |
43 | 47 | } |
44 | 48 | \ No newline at end of file |
@@ -26,18 +26,18 @@ |
||
26 | 26 | private $_keys=null; |
27 | 27 | private $_method=TMappedStatement::QUERY_FOR_LIST; |
28 | 28 | |
29 | - public function getStatement(){ return $this->_statement; } |
|
30 | - public function setStatement($value){ $this->_statement = $value; } |
|
29 | + public function getStatement() { return $this->_statement; } |
|
30 | + public function setStatement($value) { $this->_statement=$value; } |
|
31 | 31 | |
32 | - public function getResultProperty(){ return $this->_property; } |
|
33 | - public function setResultProperty($value){ $this->_property = $value; } |
|
32 | + public function getResultProperty() { return $this->_property; } |
|
33 | + public function setResultProperty($value) { $this->_property=$value; } |
|
34 | 34 | |
35 | - public function getResultObject(){ return $this->_resultObject; } |
|
36 | - public function setResultObject($value){ $this->_resultObject = $value; } |
|
35 | + public function getResultObject() { return $this->_resultObject; } |
|
36 | + public function setResultObject($value) { $this->_resultObject=$value; } |
|
37 | 37 | |
38 | - public function getKeys(){ return $this->_keys; } |
|
39 | - public function setKeys($value){ $this->_keys = $value; } |
|
38 | + public function getKeys() { return $this->_keys; } |
|
39 | + public function setKeys($value) { $this->_keys=$value; } |
|
40 | 40 | |
41 | - public function getMethod(){ return $this->_method; } |
|
42 | - public function setMethod($value){ $this->_method = $value; } |
|
41 | + public function getMethod() { return $this->_method; } |
|
42 | + public function setMethod($value) { $this->_method=$value; } |
|
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -24,6 +24,9 @@ |
||
24 | 24 | private $_parameterObject; |
25 | 25 | private $_list; |
26 | 26 | |
27 | + /** |
|
28 | + * @param \ArrayAccess $list |
|
29 | + */ |
|
27 | 30 | public function __construct($result, $parameter, &$list) |
28 | 31 | { |
29 | 32 | $this->_resultObject = $result; |
@@ -26,9 +26,9 @@ |
||
26 | 26 | |
27 | 27 | public function __construct($result, $parameter, &$list) |
28 | 28 | { |
29 | - $this->_resultObject = $result; |
|
30 | - $this->_parameterObject = $parameter; |
|
31 | - $this->_list = &$list; |
|
29 | + $this->_resultObject=$result; |
|
30 | + $this->_parameterObject=$parameter; |
|
31 | + $this->_list=&$list; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | public function getResult() |
@@ -53,6 +53,7 @@ |
||
53 | 53 | * @param string parent node id |
54 | 54 | * @param string new node id |
55 | 55 | * @param mixed node value |
56 | + * @param string $node |
|
56 | 57 | */ |
57 | 58 | public function add($parent, $node, $object='') |
58 | 59 | { |
@@ -30,22 +30,22 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @var array object graph as tree |
32 | 32 | */ |
33 | - private $_tree = array(); |
|
33 | + private $_tree=array(); |
|
34 | 34 | /** |
35 | 35 | * @var array tree node values |
36 | 36 | */ |
37 | - private $_entries = array(); |
|
37 | + private $_entries=array(); |
|
38 | 38 | /** |
39 | 39 | * @var array resulting object collection |
40 | 40 | */ |
41 | - private $_list = array(); |
|
41 | + private $_list=array(); |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @return boolean true if the graph is empty |
45 | 45 | */ |
46 | 46 | public function isEmpty() |
47 | 47 | { |
48 | - return count($this->_entries) == 0; |
|
48 | + return count($this->_entries)==0; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -59,22 +59,22 @@ discard block |
||
59 | 59 | if(isset($this->_entries[$parent]) && ($this->_entries[$parent]!==null) |
60 | 60 | && isset($this->_entries[$node]) && ($this->_entries[$node]!==null)) |
61 | 61 | { |
62 | - $this->_entries[$node] = $object; |
|
62 | + $this->_entries[$node]=$object; |
|
63 | 63 | return; |
64 | 64 | } |
65 | - $this->_entries[$node] = $object; |
|
65 | + $this->_entries[$node]=$object; |
|
66 | 66 | if(empty($parent)) |
67 | 67 | { |
68 | 68 | if(isset($this->_entries[$node])) |
69 | 69 | return; |
70 | - $this->_tree[$node] = array(); |
|
70 | + $this->_tree[$node]=array(); |
|
71 | 71 | } |
72 | - $found = $this->addNode($this->_tree, $parent, $node); |
|
72 | + $found=$this->addNode($this->_tree, $parent, $node); |
|
73 | 73 | if(!$found && !empty($parent)) |
74 | 74 | { |
75 | - $this->_tree[$parent] = array(); |
|
76 | - if(!isset($this->_entries[$parent]) || $object !== '') |
|
77 | - $this->_entries[$parent] = $object; |
|
75 | + $this->_tree[$parent]=array(); |
|
76 | + if(!isset($this->_entries[$parent]) || $object!=='') |
|
77 | + $this->_entries[$parent]=$object; |
|
78 | 78 | $this->addNode($this->_tree, $parent, $node); |
79 | 79 | } |
80 | 80 | } |
@@ -88,20 +88,20 @@ discard block |
||
88 | 88 | */ |
89 | 89 | protected function addNode(&$childs, $parent, $node) |
90 | 90 | { |
91 | - $found = false; |
|
91 | + $found=false; |
|
92 | 92 | reset($childs); |
93 | - for($i = 0, $k = count($childs); $i < $k; $i++) |
|
93 | + for($i=0, $k=count($childs); $i < $k; $i++) |
|
94 | 94 | { |
95 | - $key = key($childs); |
|
95 | + $key=key($childs); |
|
96 | 96 | next($childs); |
97 | - if($key == $parent) |
|
97 | + if($key==$parent) |
|
98 | 98 | { |
99 | - $found = true; |
|
100 | - $childs[$key][$node] = array(); |
|
99 | + $found=true; |
|
100 | + $childs[$key][$node]=array(); |
|
101 | 101 | } |
102 | 102 | else |
103 | 103 | { |
104 | - $found = $found || $this->addNode($childs[$key], $parent, $node); |
|
104 | + $found=$found || $this->addNode($childs[$key], $parent, $node); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | return $found; |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | */ |
124 | 124 | protected function hasChildren(&$nodes) |
125 | 125 | { |
126 | - $hasChildren = false; |
|
126 | + $hasChildren=false; |
|
127 | 127 | foreach($nodes as $node) |
128 | - if(count($node) != 0) |
|
128 | + if(count($node)!=0) |
|
129 | 129 | return true; |
130 | 130 | return $hasChildren; |
131 | 131 | } |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | */ |
138 | 138 | protected function collectChildren($parent, &$nodes) |
139 | 139 | { |
140 | - $noChildren = !$this->hasChildren($nodes); |
|
141 | - $childs = array(); |
|
142 | - for(reset($nodes); $key = key($nodes);) |
|
140 | + $noChildren=!$this->hasChildren($nodes); |
|
141 | + $childs=array(); |
|
142 | + for(reset($nodes); $key=key($nodes);) |
|
143 | 143 | { |
144 | 144 | next($nodes); |
145 | 145 | if($noChildren) |
146 | 146 | { |
147 | - $childs[] = $key; |
|
147 | + $childs[]=$key; |
|
148 | 148 | unset($nodes[$key]); |
149 | 149 | } |
150 | 150 | else |
@@ -164,17 +164,17 @@ discard block |
||
164 | 164 | if(empty($parent) || empty($this->_entries[$parent])) |
165 | 165 | return; |
166 | 166 | |
167 | - $parentObject = $this->_entries[$parent]['object']; |
|
168 | - $property = $this->_entries[$nodes[0]]['property']; |
|
167 | + $parentObject=$this->_entries[$parent]['object']; |
|
168 | + $property=$this->_entries[$nodes[0]]['property']; |
|
169 | 169 | |
170 | - $list = TPropertyAccess::get($parentObject, $property); |
|
170 | + $list=TPropertyAccess::get($parentObject, $property); |
|
171 | 171 | |
172 | 172 | foreach($nodes as $node) |
173 | 173 | { |
174 | 174 | if($list instanceof TList) |
175 | - $parentObject->{$property}[] = $this->_entries[$node]['object']; |
|
175 | + $parentObject->{$property}[]=$this->_entries[$node]['object']; |
|
176 | 176 | else if(is_array($list)) |
177 | - $list[] = $this->_entries[$node]['object']; |
|
177 | + $list[]=$this->_entries[$node]['object']; |
|
178 | 178 | else |
179 | 179 | throw new TSqlMapExecutionException( |
180 | 180 | 'sqlmap_property_must_be_list'); |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | if(is_array($list)) |
184 | 184 | TPropertyAccess::set($parentObject, $property, $list); |
185 | 185 | |
186 | - if($this->_entries[$parent]['property'] === null) |
|
187 | - $this->_list[] = $parentObject; |
|
186 | + if($this->_entries[$parent]['property']===null) |
|
187 | + $this->_list[]=$parentObject; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | |
198 | 198 | public function __sleep() |
199 | 199 | { |
200 | - $exprops = array(); $cn = __CLASS__; |
|
201 | - if (!count($this->_tree)) $exprops[] = "\0$cn\0_tree"; |
|
202 | - if (!count($this->_entries)) $exprops[] = "\0$cn\0_entries"; |
|
203 | - if (!count($this->_list)) $exprops[] = "\0$cn\0_list"; |
|
204 | - return array_diff(parent::__sleep(),$exprops); |
|
200 | + $exprops=array(); $cn=__CLASS__; |
|
201 | + if(!count($this->_tree)) $exprops[]="\0$cn\0_tree"; |
|
202 | + if(!count($this->_entries)) $exprops[]="\0$cn\0_entries"; |
|
203 | + if(!count($this->_list)) $exprops[]="\0$cn\0_list"; |
|
204 | + return array_diff(parent::__sleep(), $exprops); |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | \ No newline at end of file |
@@ -98,8 +98,7 @@ discard block |
||
98 | 98 | { |
99 | 99 | $found = true; |
100 | 100 | $childs[$key][$node] = array(); |
101 | - } |
|
102 | - else |
|
101 | + } else |
|
103 | 102 | { |
104 | 103 | $found = $found || $this->addNode($childs[$key], $parent, $node); |
105 | 104 | } |
@@ -112,8 +111,9 @@ discard block |
||
112 | 111 | */ |
113 | 112 | public function collect() |
114 | 113 | { |
115 | - while(count($this->_tree) > 0) |
|
116 | - $this->collectChildren(null, $this->_tree); |
|
114 | + while(count($this->_tree) > 0) { |
|
115 | + $this->collectChildren(null, $this->_tree); |
|
116 | + } |
|
117 | 117 | return $this->getCollection(); |
118 | 118 | } |
119 | 119 | |
@@ -146,8 +146,7 @@ discard block |
||
146 | 146 | { |
147 | 147 | $childs[] = $key; |
148 | 148 | unset($nodes[$key]); |
149 | - } |
|
150 | - else |
|
149 | + } else |
|
151 | 150 | $this->collectChildren($key, $nodes[$key]); |
152 | 151 | } |
153 | 152 | if(count($childs) > 0) |
@@ -393,6 +393,8 @@ |
||
393 | 393 | * in the message file. If so, the message in the preferred language |
394 | 394 | * will be used as the error message. Any rest parameters will be used |
395 | 395 | * to replace placeholders ({0}, {1}, {2}, etc.) in the message. |
396 | + * @param integer $statusCode |
|
397 | + * @param string $errorMessage |
|
396 | 398 | */ |
397 | 399 | public function __construct($statusCode,$errorMessage) |
398 | 400 | { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * will be used as the error message. Any rest parameters will be used |
36 | 36 | * to replace placeholders ({0}, {1}, {2}, etc.) in the message. |
37 | 37 | */ |
38 | - public function __construct($statusCode,$errorMessage) |
|
38 | + public function __construct($statusCode, $errorMessage) |
|
39 | 39 | { |
40 | 40 | $this->_statusCode=$statusCode; |
41 | 41 | $this->setErrorCode($errorMessage); |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | array_shift($args); |
46 | 46 | $n=count($args); |
47 | 47 | $tokens=array(); |
48 | - for($i=0;$i<$n;++$i) |
|
48 | + for($i=0; $i < $n; ++$i) |
|
49 | 49 | $tokens['{'.$i.'}']=TPropertyValue::ensureString($args[$i]); |
50 | - parent::__construct(strtr($errorMessage,$tokens)); |
|
50 | + parent::__construct(strtr($errorMessage, $tokens)); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |