@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function __construct($resultMap = null) |
65 | 65 | { |
66 | - if($resultMap instanceof TResultMap) |
|
66 | + if ($resultMap instanceof TResultMap) |
|
67 | 67 | $this->_hostResultMapID = $resultMap->getID(); |
68 | 68 | } |
69 | 69 | |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | $value = null; |
245 | 245 | $index = $this->getColumnIndex(); |
246 | 246 | $name = $this->getColumn(); |
247 | - if($index > 0 && isset($row[$index])) |
|
247 | + if ($index > 0 && isset($row[$index])) |
|
248 | 248 | $value = $this->getTypedValue($registry, $row[$index]); |
249 | - elseif(isset($row[$name])) |
|
249 | + elseif (isset($row[$name])) |
|
250 | 250 | $value = $this->getTypedValue($registry, $row[$name]); |
251 | - if(($value === null) && ($this->getNullValue() !== null)) |
|
251 | + if (($value === null) && ($this->getNullValue() !== null)) |
|
252 | 252 | $value = $this->getTypedValue($registry, $this->getNullValue()); |
253 | 253 | return $value; |
254 | 254 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | */ |
261 | 261 | protected function getTypedValue($registry, $value) |
262 | 262 | { |
263 | - if(($handler = $this->createTypeHandler($registry)) !== null) |
|
263 | + if (($handler = $this->createTypeHandler($registry)) !== null) |
|
264 | 264 | return $handler->getResult($value); |
265 | 265 | else |
266 | 266 | return $registry->convertToType($this->getType(), $value); |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | { |
276 | 276 | $type = $this->getTypeHandler() ? $this->getTypeHandler() : $this->getType(); |
277 | 277 | $handler = $registry->getTypeHandler($type); |
278 | - if($handler === null && $this->getTypeHandler()) |
|
278 | + if ($handler === null && $this->getTypeHandler()) |
|
279 | 279 | $handler = Prado::createComponent($type); |
280 | 280 | return $handler; |
281 | 281 | } |
@@ -286,17 +286,17 @@ discard block |
||
286 | 286 | */ |
287 | 287 | protected function getPropertyValueType() |
288 | 288 | { |
289 | - if(class_exists($type = $this->getType(), false)) //NO force autoloading |
|
289 | + if (class_exists($type = $this->getType(), false)) //NO force autoloading |
|
290 | 290 | { |
291 | - if($type === 'TList') |
|
291 | + if ($type === 'TList') |
|
292 | 292 | return self::LIST_TYPE; |
293 | 293 | $class = new ReflectionClass($type); |
294 | - if($class->isSubclassOf('TList')) |
|
294 | + if ($class->isSubclassOf('TList')) |
|
295 | 295 | return self::LIST_TYPE; |
296 | - if($class->implementsInterface('ArrayAccess')) |
|
296 | + if ($class->implementsInterface('ArrayAccess')) |
|
297 | 297 | return self::ARRAY_TYPE; |
298 | 298 | } |
299 | - if(strtolower($type) == 'array') |
|
299 | + if (strtolower($type) == 'array') |
|
300 | 300 | return self::ARRAY_TYPE; |
301 | 301 | } |
302 | 302 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | */ |
309 | 309 | public function instanceOfListType($target) |
310 | 310 | { |
311 | - if($this->getType() === null) |
|
311 | + if ($this->getType() === null) |
|
312 | 312 | return TPropertyAccess::get($target, $this->getProperty()) instanceof TList; |
313 | 313 | return $this->getPropertyValueType() == self::LIST_TYPE; |
314 | 314 | } |
@@ -321,10 +321,10 @@ discard block |
||
321 | 321 | */ |
322 | 322 | public function instanceOfArrayType($target) |
323 | 323 | { |
324 | - if($this->getType() === null) |
|
324 | + if ($this->getType() === null) |
|
325 | 325 | { |
326 | 326 | $prop = TPropertyAccess::get($target, $this->getProperty()); |
327 | - if(is_object($prop)) |
|
327 | + if (is_object($prop)) |
|
328 | 328 | return $prop instanceof \ArrayAccess; |
329 | 329 | return is_array($prop); |
330 | 330 | } |
@@ -63,8 +63,9 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function __construct($resultMap = null) |
65 | 65 | { |
66 | - if($resultMap instanceof TResultMap) |
|
67 | - $this->_hostResultMapID = $resultMap->getID(); |
|
66 | + if($resultMap instanceof TResultMap) { |
|
67 | + $this->_hostResultMapID = $resultMap->getID(); |
|
68 | + } |
|
68 | 69 | } |
69 | 70 | |
70 | 71 | /** |
@@ -244,12 +245,14 @@ discard block |
||
244 | 245 | $value = null; |
245 | 246 | $index = $this->getColumnIndex(); |
246 | 247 | $name = $this->getColumn(); |
247 | - if($index > 0 && isset($row[$index])) |
|
248 | - $value = $this->getTypedValue($registry, $row[$index]); |
|
249 | - elseif(isset($row[$name])) |
|
250 | - $value = $this->getTypedValue($registry, $row[$name]); |
|
251 | - if(($value === null) && ($this->getNullValue() !== null)) |
|
252 | - $value = $this->getTypedValue($registry, $this->getNullValue()); |
|
248 | + if($index > 0 && isset($row[$index])) { |
|
249 | + $value = $this->getTypedValue($registry, $row[$index]); |
|
250 | + } elseif(isset($row[$name])) { |
|
251 | + $value = $this->getTypedValue($registry, $row[$name]); |
|
252 | + } |
|
253 | + if(($value === null) && ($this->getNullValue() !== null)) { |
|
254 | + $value = $this->getTypedValue($registry, $this->getNullValue()); |
|
255 | + } |
|
253 | 256 | return $value; |
254 | 257 | } |
255 | 258 | |
@@ -260,10 +263,11 @@ discard block |
||
260 | 263 | */ |
261 | 264 | protected function getTypedValue($registry, $value) |
262 | 265 | { |
263 | - if(($handler = $this->createTypeHandler($registry)) !== null) |
|
264 | - return $handler->getResult($value); |
|
265 | - else |
|
266 | - return $registry->convertToType($this->getType(), $value); |
|
266 | + if(($handler = $this->createTypeHandler($registry)) !== null) { |
|
267 | + return $handler->getResult($value); |
|
268 | + } else { |
|
269 | + return $registry->convertToType($this->getType(), $value); |
|
270 | + } |
|
267 | 271 | } |
268 | 272 | |
269 | 273 | /** |
@@ -275,8 +279,9 @@ discard block |
||
275 | 279 | { |
276 | 280 | $type = $this->getTypeHandler() ? $this->getTypeHandler() : $this->getType(); |
277 | 281 | $handler = $registry->getTypeHandler($type); |
278 | - if($handler === null && $this->getTypeHandler()) |
|
279 | - $handler = Prado::createComponent($type); |
|
282 | + if($handler === null && $this->getTypeHandler()) { |
|
283 | + $handler = Prado::createComponent($type); |
|
284 | + } |
|
280 | 285 | return $handler; |
281 | 286 | } |
282 | 287 | |
@@ -286,18 +291,23 @@ discard block |
||
286 | 291 | */ |
287 | 292 | protected function getPropertyValueType() |
288 | 293 | { |
289 | - if(class_exists($type = $this->getType(), false)) //NO force autoloading |
|
294 | + if(class_exists($type = $this->getType(), false)) { |
|
295 | + //NO force autoloading |
|
290 | 296 | { |
291 | 297 | if($type === 'TList') |
292 | 298 | return self::LIST_TYPE; |
299 | + } |
|
293 | 300 | $class = new ReflectionClass($type); |
294 | - if($class->isSubclassOf('TList')) |
|
295 | - return self::LIST_TYPE; |
|
296 | - if($class->implementsInterface('ArrayAccess')) |
|
297 | - return self::ARRAY_TYPE; |
|
301 | + if($class->isSubclassOf('TList')) { |
|
302 | + return self::LIST_TYPE; |
|
303 | + } |
|
304 | + if($class->implementsInterface('ArrayAccess')) { |
|
305 | + return self::ARRAY_TYPE; |
|
306 | + } |
|
307 | + } |
|
308 | + if(strtolower($type) == 'array') { |
|
309 | + return self::ARRAY_TYPE; |
|
298 | 310 | } |
299 | - if(strtolower($type) == 'array') |
|
300 | - return self::ARRAY_TYPE; |
|
301 | 311 | } |
302 | 312 | |
303 | 313 | /** |
@@ -308,8 +318,9 @@ discard block |
||
308 | 318 | */ |
309 | 319 | public function instanceOfListType($target) |
310 | 320 | { |
311 | - if($this->getType() === null) |
|
312 | - return TPropertyAccess::get($target, $this->getProperty()) instanceof TList; |
|
321 | + if($this->getType() === null) { |
|
322 | + return TPropertyAccess::get($target, $this->getProperty()) instanceof TList; |
|
323 | + } |
|
313 | 324 | return $this->getPropertyValueType() == self::LIST_TYPE; |
314 | 325 | } |
315 | 326 | |
@@ -324,8 +335,9 @@ discard block |
||
324 | 335 | if($this->getType() === null) |
325 | 336 | { |
326 | 337 | $prop = TPropertyAccess::get($target, $this->getProperty()); |
327 | - if(is_object($prop)) |
|
328 | - return $prop instanceof \ArrayAccess; |
|
338 | + if(is_object($prop)) { |
|
339 | + return $prop instanceof \ArrayAccess; |
|
340 | + } |
|
329 | 341 | return is_array($prop); |
330 | 342 | } |
331 | 343 | return $this->getPropertyValueType() == self::ARRAY_TYPE; |
@@ -334,16 +346,36 @@ discard block |
||
334 | 346 | public function __sleep() |
335 | 347 | { |
336 | 348 | $exprops = []; $cn = 'TResultProperty'; |
337 | - if ($this->_nullValue === null) $exprops[] = "\0$cn\0_nullValue"; |
|
338 | - if ($this->_propertyName === null) $exprops[] = "\0$cn\0_propertyNama"; |
|
339 | - if ($this->_columnName === null) $exprops[] = "\0$cn\0_columnName"; |
|
340 | - if ($this->_columnIndex == -1) $exprops[] = "\0$cn\0_columnIndex"; |
|
341 | - if ($this->_nestedResultMapName === null) $exprops[] = "\0$cn\0_nestedResultMapName"; |
|
342 | - if ($this->_nestedResultMap === null) $exprops[] = "\0$cn\0_nestedResultMap"; |
|
343 | - if ($this->_valueType === null) $exprops[] = "\0$cn\0_valueType"; |
|
344 | - if ($this->_typeHandler === null) $exprops[] = "\0$cn\0_typeHandler"; |
|
345 | - if ($this->_isLazyLoad === false) $exprops[] = "\0$cn\0_isLazyLoad"; |
|
346 | - if ($this->_select === null) $exprops[] = "\0$cn\0_select"; |
|
349 | + if ($this->_nullValue === null) { |
|
350 | + $exprops[] = "\0$cn\0_nullValue"; |
|
351 | + } |
|
352 | + if ($this->_propertyName === null) { |
|
353 | + $exprops[] = "\0$cn\0_propertyNama"; |
|
354 | + } |
|
355 | + if ($this->_columnName === null) { |
|
356 | + $exprops[] = "\0$cn\0_columnName"; |
|
357 | + } |
|
358 | + if ($this->_columnIndex == -1) { |
|
359 | + $exprops[] = "\0$cn\0_columnIndex"; |
|
360 | + } |
|
361 | + if ($this->_nestedResultMapName === null) { |
|
362 | + $exprops[] = "\0$cn\0_nestedResultMapName"; |
|
363 | + } |
|
364 | + if ($this->_nestedResultMap === null) { |
|
365 | + $exprops[] = "\0$cn\0_nestedResultMap"; |
|
366 | + } |
|
367 | + if ($this->_valueType === null) { |
|
368 | + $exprops[] = "\0$cn\0_valueType"; |
|
369 | + } |
|
370 | + if ($this->_typeHandler === null) { |
|
371 | + $exprops[] = "\0$cn\0_typeHandler"; |
|
372 | + } |
|
373 | + if ($this->_isLazyLoad === false) { |
|
374 | + $exprops[] = "\0$cn\0_isLazyLoad"; |
|
375 | + } |
|
376 | + if ($this->_select === null) { |
|
377 | + $exprops[] = "\0$cn\0_select"; |
|
378 | + } |
|
347 | 379 | return array_diff(parent::__sleep(), $exprops); |
348 | 380 | } |
349 | 381 | } |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public function initialize($manager) |
250 | 250 | { |
251 | - if(strlen($this->_resultMapName) > 0) |
|
251 | + if (strlen($this->_resultMapName) > 0) |
|
252 | 252 | $this->_resultMap = $manager->getResultMap($this->_resultMapName); |
253 | - if(strlen($this->_parameterMapName) > 0) |
|
253 | + if (strlen($this->_parameterMapName) > 0) |
|
254 | 254 | $this->_parameterMap = $manager->getParameterMap($this->_parameterMapName); |
255 | 255 | } |
256 | 256 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function createInstanceOfListClass($registry) |
262 | 262 | { |
263 | - if(strlen($type = $this->getListClass()) > 0) |
|
263 | + if (strlen($type = $this->getListClass()) > 0) |
|
264 | 264 | return $this->createInstanceOf($registry, $type); |
265 | 265 | return []; |
266 | 266 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | protected function createInstanceOf($registry, $type, $row = null) |
276 | 276 | { |
277 | 277 | $handler = $registry->getTypeHandler($type); |
278 | - if($handler !== null) |
|
278 | + if ($handler !== null) |
|
279 | 279 | return $handler->createNewInstance($row); |
280 | 280 | else |
281 | 281 | return $registry->createInstanceOf($type); |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | */ |
290 | 290 | public function createInstanceOfResultClass($registry, $row) |
291 | 291 | { |
292 | - if(strlen($type = $this->getResultClass()) > 0) |
|
292 | + if (strlen($type = $this->getResultClass()) > 0) |
|
293 | 293 | return $this->createInstanceOf($registry, $type, $row); |
294 | 294 | } |
295 | 295 |
@@ -248,10 +248,12 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public function initialize($manager) |
250 | 250 | { |
251 | - if(strlen($this->_resultMapName) > 0) |
|
252 | - $this->_resultMap = $manager->getResultMap($this->_resultMapName); |
|
253 | - if(strlen($this->_parameterMapName) > 0) |
|
254 | - $this->_parameterMap = $manager->getParameterMap($this->_parameterMapName); |
|
251 | + if(strlen($this->_resultMapName) > 0) { |
|
252 | + $this->_resultMap = $manager->getResultMap($this->_resultMapName); |
|
253 | + } |
|
254 | + if(strlen($this->_parameterMapName) > 0) { |
|
255 | + $this->_parameterMap = $manager->getParameterMap($this->_parameterMapName); |
|
256 | + } |
|
255 | 257 | } |
256 | 258 | |
257 | 259 | /** |
@@ -260,8 +262,9 @@ discard block |
||
260 | 262 | */ |
261 | 263 | public function createInstanceOfListClass($registry) |
262 | 264 | { |
263 | - if(strlen($type = $this->getListClass()) > 0) |
|
264 | - return $this->createInstanceOf($registry, $type); |
|
265 | + if(strlen($type = $this->getListClass()) > 0) { |
|
266 | + return $this->createInstanceOf($registry, $type); |
|
267 | + } |
|
265 | 268 | return []; |
266 | 269 | } |
267 | 270 | |
@@ -275,10 +278,11 @@ discard block |
||
275 | 278 | protected function createInstanceOf($registry, $type, $row = null) |
276 | 279 | { |
277 | 280 | $handler = $registry->getTypeHandler($type); |
278 | - if($handler !== null) |
|
279 | - return $handler->createNewInstance($row); |
|
280 | - else |
|
281 | - return $registry->createInstanceOf($type); |
|
281 | + if($handler !== null) { |
|
282 | + return $handler->createNewInstance($row); |
|
283 | + } else { |
|
284 | + return $registry->createInstanceOf($type); |
|
285 | + } |
|
282 | 286 | } |
283 | 287 | |
284 | 288 | /** |
@@ -289,26 +293,51 @@ discard block |
||
289 | 293 | */ |
290 | 294 | public function createInstanceOfResultClass($registry, $row) |
291 | 295 | { |
292 | - if(strlen($type = $this->getResultClass()) > 0) |
|
293 | - return $this->createInstanceOf($registry, $type, $row); |
|
296 | + if(strlen($type = $this->getResultClass()) > 0) { |
|
297 | + return $this->createInstanceOf($registry, $type, $row); |
|
298 | + } |
|
294 | 299 | } |
295 | 300 | |
296 | 301 | public function __sleep() |
297 | 302 | { |
298 | 303 | $cn = __CLASS__; |
299 | 304 | $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"; |
|
305 | + if (!$this->_parameterMapName) { |
|
306 | + $exprops[] = "\0$cn\0_parameterMapName"; |
|
307 | + } |
|
308 | + if (!$this->_parameterMap) { |
|
309 | + $exprops[] = "\0$cn\0_parameterMap"; |
|
310 | + } |
|
311 | + if (!$this->_parameterClassName) { |
|
312 | + $exprops[] = "\0$cn\0_parameterClassName"; |
|
313 | + } |
|
314 | + if (!$this->_resultMapName) { |
|
315 | + $exprops[] = "\0$cn\0_resultMapName"; |
|
316 | + } |
|
317 | + if (!$this->_resultMap) { |
|
318 | + $exprops[] = "\0$cn\0_resultMap"; |
|
319 | + } |
|
320 | + if (!$this->_resultClassName) { |
|
321 | + $exprops[] = "\0$cn\0_resultClassName"; |
|
322 | + } |
|
323 | + if (!$this->_cacheModelName) { |
|
324 | + $exprops[] = "\0$cn\0_cacheModelName"; |
|
325 | + } |
|
326 | + if (!$this->_SQL) { |
|
327 | + $exprops[] = "\0$cn\0_SQL"; |
|
328 | + } |
|
329 | + if (!$this->_listClass) { |
|
330 | + $exprops[] = "\0$cn\0_listClass"; |
|
331 | + } |
|
332 | + if (!$this->_typeHandler) { |
|
333 | + $exprops[] = "\0$cn\0_typeHandler"; |
|
334 | + } |
|
335 | + if (!$this->_extendStatement) { |
|
336 | + $exprops[] = "\0$cn\0_extendStatement"; |
|
337 | + } |
|
338 | + if (!$this->_cache) { |
|
339 | + $exprops[] = "\0$cn\0_cache"; |
|
340 | + } |
|
312 | 341 | |
313 | 342 | return array_diff(parent::__sleep(), $exprops); |
314 | 343 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | private function getCacheKey() |
45 | 45 | { |
46 | - return $this->getID() . $this->getConfigFile(); |
|
46 | + return $this->getID().$this->getConfigFile(); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | public function clearCache() |
53 | 53 | { |
54 | 54 | $cache = $this->getApplication()->getCache(); |
55 | - if($cache !== null) { |
|
55 | + if ($cache !== null) { |
|
56 | 56 | $cache->delete($this->getCacheKey()); |
57 | 57 | } |
58 | 58 | } |
@@ -66,16 +66,16 @@ discard block |
||
66 | 66 | * @since 3.1.7 |
67 | 67 | */ |
68 | 68 | public function getSqlMapManager() { |
69 | - if(($manager = $this->loadCachedSqlMapManager()) === null) |
|
69 | + if (($manager = $this->loadCachedSqlMapManager()) === null) |
|
70 | 70 | { |
71 | 71 | $manager = new TSqlMapManager($this->getDbConnection()); |
72 | - if(strlen($file = $this->getConfigFile()) > 0) |
|
72 | + if (strlen($file = $this->getConfigFile()) > 0) |
|
73 | 73 | { |
74 | 74 | $manager->configureXml($file); |
75 | 75 | $this->cacheSqlMapManager($manager); |
76 | 76 | } |
77 | 77 | } |
78 | - elseif($this->getConnectionID() !== '') { |
|
78 | + elseif ($this->getConnectionID() !== '') { |
|
79 | 79 | $manager->setDbConnection($this->getDbConnection()); |
80 | 80 | } |
81 | 81 | return $manager; |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | */ |
88 | 88 | protected function cacheSqlMapManager($manager) |
89 | 89 | { |
90 | - if($this->getEnableCache()) |
|
90 | + if ($this->getEnableCache()) |
|
91 | 91 | { |
92 | 92 | $cache = $this->getApplication()->getCache(); |
93 | - if($cache !== null) { |
|
93 | + if ($cache !== null) { |
|
94 | 94 | $dependencies = null; |
95 | - if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
95 | + if ($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
96 | 96 | $dependencies = $manager->getCacheDependencies(); |
97 | 97 | return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); |
98 | 98 | } |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function loadCachedSqlMapManager() |
108 | 108 | { |
109 | - if($this->getEnableCache()) |
|
109 | + if ($this->getEnableCache()) |
|
110 | 110 | { |
111 | 111 | $cache = $this->getApplication()->getCache(); |
112 | - if($cache !== null) |
|
112 | + if ($cache !== null) |
|
113 | 113 | { |
114 | 114 | $manager = $cache->get($this->getCacheKey()); |
115 | - if($manager instanceof TSqlMapManager) |
|
115 | + if ($manager instanceof TSqlMapManager) |
|
116 | 116 | return $manager; |
117 | 117 | } |
118 | 118 | } |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function setConfigFile($value) |
136 | 136 | { |
137 | - if(is_file($value)) |
|
137 | + if (is_file($value)) |
|
138 | 138 | $this->_configFile = $value; |
139 | 139 | else |
140 | 140 | { |
141 | 141 | $file = Prado::getPathOfNamespace($value, self::CONFIG_FILE_EXT); |
142 | - if($file === null || !is_file($file)) |
|
142 | + if ($file === null || !is_file($file)) |
|
143 | 143 | throw new TConfigurationException('sqlmap_configfile_invalid', $value); |
144 | 144 | else |
145 | 145 | $this->_configFile = $file; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public function getClient() |
179 | 179 | { |
180 | - if($this->_sqlmap === null) |
|
180 | + if ($this->_sqlmap === null) |
|
181 | 181 | $this->_sqlmap = $this->createSqlMapGateway(); |
182 | 182 | return $this->_sqlmap; |
183 | 183 | } |
@@ -74,8 +74,7 @@ discard block |
||
74 | 74 | $manager->configureXml($file); |
75 | 75 | $this->cacheSqlMapManager($manager); |
76 | 76 | } |
77 | - } |
|
78 | - elseif($this->getConnectionID() !== '') { |
|
77 | + } elseif($this->getConnectionID() !== '') { |
|
79 | 78 | $manager->setDbConnection($this->getDbConnection()); |
80 | 79 | } |
81 | 80 | return $manager; |
@@ -92,8 +91,9 @@ discard block |
||
92 | 91 | $cache = $this->getApplication()->getCache(); |
93 | 92 | if($cache !== null) { |
94 | 93 | $dependencies = null; |
95 | - if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
96 | - $dependencies = $manager->getCacheDependencies(); |
|
94 | + if($this->getApplication()->getMode() !== TApplicationMode::Performance) { |
|
95 | + $dependencies = $manager->getCacheDependencies(); |
|
96 | + } |
|
97 | 97 | return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); |
98 | 98 | } |
99 | 99 | } |
@@ -112,8 +112,9 @@ discard block |
||
112 | 112 | if($cache !== null) |
113 | 113 | { |
114 | 114 | $manager = $cache->get($this->getCacheKey()); |
115 | - if($manager instanceof TSqlMapManager) |
|
116 | - return $manager; |
|
115 | + if($manager instanceof TSqlMapManager) { |
|
116 | + return $manager; |
|
117 | + } |
|
117 | 118 | } |
118 | 119 | } |
119 | 120 | return null; |
@@ -134,15 +135,16 @@ discard block |
||
134 | 135 | */ |
135 | 136 | public function setConfigFile($value) |
136 | 137 | { |
137 | - if(is_file($value)) |
|
138 | - $this->_configFile = $value; |
|
139 | - else |
|
138 | + if(is_file($value)) { |
|
139 | + $this->_configFile = $value; |
|
140 | + } else |
|
140 | 141 | { |
141 | 142 | $file = Prado::getPathOfNamespace($value, self::CONFIG_FILE_EXT); |
142 | - if($file === null || !is_file($file)) |
|
143 | - throw new TConfigurationException('sqlmap_configfile_invalid', $value); |
|
144 | - else |
|
145 | - $this->_configFile = $file; |
|
143 | + if($file === null || !is_file($file)) { |
|
144 | + throw new TConfigurationException('sqlmap_configfile_invalid', $value); |
|
145 | + } else { |
|
146 | + $this->_configFile = $file; |
|
147 | + } |
|
146 | 148 | } |
147 | 149 | } |
148 | 150 | |
@@ -177,8 +179,9 @@ discard block |
||
177 | 179 | */ |
178 | 180 | public function getClient() |
179 | 181 | { |
180 | - if($this->_sqlmap === null) |
|
181 | - $this->_sqlmap = $this->createSqlMapGateway(); |
|
182 | + if($this->_sqlmap === null) { |
|
183 | + $this->_sqlmap = $this->createSqlMapGateway(); |
|
184 | + } |
|
182 | 185 | return $this->_sqlmap; |
183 | 186 | } |
184 | 187 | } |
@@ -32,10 +32,10 @@ |
||
32 | 32 | |
33 | 33 | public function replaceDynamicParameter($sql, $parameter) |
34 | 34 | { |
35 | - foreach($this->_mappings as $property) |
|
35 | + foreach ($this->_mappings as $property) |
|
36 | 36 | { |
37 | 37 | $value = TPropertyAccess::get($parameter, $property); |
38 | - $sql = preg_replace('/' . TSimpleDynamicParser::DYNAMIC_TOKEN . '/', str_replace('$', '\$', $value), $sql, 1); |
|
38 | + $sql = preg_replace('/'.TSimpleDynamicParser::DYNAMIC_TOKEN.'/', str_replace('$', '\$', $value), $sql, 1); |
|
39 | 39 | } |
40 | 40 | return $sql; |
41 | 41 | } |
@@ -35,14 +35,14 @@ |
||
35 | 35 | { |
36 | 36 | $this->_preparedStatement = new TPreparedStatement(); |
37 | 37 | $this->_preparedStatement->setPreparedSql($this->_commandText); |
38 | - if($this->_statement->parameterMap() !== null) |
|
38 | + if ($this->_statement->parameterMap() !== null) |
|
39 | 39 | $this->createParametersForTextCommand(); |
40 | 40 | return $this->_preparedStatement; |
41 | 41 | } |
42 | 42 | |
43 | 43 | protected function createParametersForTextCommand() |
44 | 44 | { |
45 | - foreach($this->_statement->ParameterMap()->getProperties() as $prop) |
|
45 | + foreach ($this->_statement->ParameterMap()->getProperties() as $prop) |
|
46 | 46 | $this->_preparedStatement->getParameterNames()->add($prop->getProperty()); |
47 | 47 | } |
48 | 48 | } |
@@ -35,15 +35,17 @@ |
||
35 | 35 | { |
36 | 36 | $this->_preparedStatement = new TPreparedStatement(); |
37 | 37 | $this->_preparedStatement->setPreparedSql($this->_commandText); |
38 | - if($this->_statement->parameterMap() !== null) |
|
39 | - $this->createParametersForTextCommand(); |
|
38 | + if($this->_statement->parameterMap() !== null) { |
|
39 | + $this->createParametersForTextCommand(); |
|
40 | + } |
|
40 | 41 | return $this->_preparedStatement; |
41 | 42 | } |
42 | 43 | |
43 | 44 | protected function createParametersForTextCommand() |
44 | 45 | { |
45 | - foreach($this->_statement->ParameterMap()->getProperties() as $prop) |
|
46 | - $this->_preparedStatement->getParameterNames()->add($prop->getProperty()); |
|
46 | + foreach($this->_statement->ParameterMap()->getProperties() as $prop) { |
|
47 | + $this->_preparedStatement->getParameterNames()->add($prop->getProperty()); |
|
48 | + } |
|
47 | 49 | } |
48 | 50 | } |
49 | 51 |
@@ -57,24 +57,24 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function add($parent, $node, $object = '') |
59 | 59 | { |
60 | - if(isset($this->_entries[$parent]) && ($this->_entries[$parent] !== null) |
|
60 | + if (isset($this->_entries[$parent]) && ($this->_entries[$parent] !== null) |
|
61 | 61 | && isset($this->_entries[$node]) && ($this->_entries[$node] !== null)) |
62 | 62 | { |
63 | 63 | $this->_entries[$node] = $object; |
64 | 64 | return; |
65 | 65 | } |
66 | 66 | $this->_entries[$node] = $object; |
67 | - if(empty($parent)) |
|
67 | + if (empty($parent)) |
|
68 | 68 | { |
69 | - if(isset($this->_entries[$node])) |
|
69 | + if (isset($this->_entries[$node])) |
|
70 | 70 | return; |
71 | 71 | $this->_tree[$node] = []; |
72 | 72 | } |
73 | 73 | $found = $this->addNode($this->_tree, $parent, $node); |
74 | - if(!$found && !empty($parent)) |
|
74 | + if (!$found && !empty($parent)) |
|
75 | 75 | { |
76 | 76 | $this->_tree[$parent] = []; |
77 | - if(!isset($this->_entries[$parent]) || $object !== '') |
|
77 | + if (!isset($this->_entries[$parent]) || $object !== '') |
|
78 | 78 | $this->_entries[$parent] = $object; |
79 | 79 | $this->addNode($this->_tree, $parent, $node); |
80 | 80 | } |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | { |
92 | 92 | $found = false; |
93 | 93 | reset($childs); |
94 | - for($i = 0, $k = count($childs); $i < $k; $i++) |
|
94 | + for ($i = 0, $k = count($childs); $i < $k; $i++) |
|
95 | 95 | { |
96 | 96 | $key = key($childs); |
97 | 97 | next($childs); |
98 | - if($key == $parent) |
|
98 | + if ($key == $parent) |
|
99 | 99 | { |
100 | 100 | $found = true; |
101 | 101 | $childs[$key][$node] = []; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function collect() |
115 | 115 | { |
116 | - while(count($this->_tree) > 0) |
|
116 | + while (count($this->_tree) > 0) |
|
117 | 117 | $this->collectChildren(null, $this->_tree); |
118 | 118 | return $this->getCollection(); |
119 | 119 | } |
@@ -125,8 +125,8 @@ 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 | return $hasChildren; |
132 | 132 | } |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | { |
141 | 141 | $noChildren = !$this->hasChildren($nodes); |
142 | 142 | $childs = []; |
143 | - for(reset($nodes); $key = key($nodes);) |
|
143 | + for (reset($nodes); $key = key($nodes);) |
|
144 | 144 | { |
145 | 145 | next($nodes); |
146 | - if($noChildren) |
|
146 | + if ($noChildren) |
|
147 | 147 | { |
148 | 148 | $childs[] = $key; |
149 | 149 | unset($nodes[$key]); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | else |
152 | 152 | $this->collectChildren($key, $nodes[$key]); |
153 | 153 | } |
154 | - if(count($childs) > 0) |
|
154 | + if (count($childs) > 0) |
|
155 | 155 | $this->onChildNodesVisited($parent, $childs); |
156 | 156 | } |
157 | 157 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | protected function onChildNodesVisited($parent, $nodes) |
164 | 164 | { |
165 | - if(empty($parent) || empty($this->_entries[$parent])) |
|
165 | + if (empty($parent) || empty($this->_entries[$parent])) |
|
166 | 166 | return; |
167 | 167 | |
168 | 168 | $parentObject = $this->_entries[$parent]['object']; |
@@ -170,21 +170,21 @@ discard block |
||
170 | 170 | |
171 | 171 | $list = TPropertyAccess::get($parentObject, $property); |
172 | 172 | |
173 | - foreach($nodes as $node) |
|
173 | + foreach ($nodes as $node) |
|
174 | 174 | { |
175 | - if($list instanceof TList) |
|
175 | + if ($list instanceof TList) |
|
176 | 176 | $parentObject->{$property}[] = $this->_entries[$node]['object']; |
177 | - elseif(is_array($list)) |
|
177 | + elseif (is_array($list)) |
|
178 | 178 | $list[] = $this->_entries[$node]['object']; |
179 | 179 | else |
180 | 180 | throw new TSqlMapExecutionException( |
181 | 181 | 'sqlmap_property_must_be_list'); |
182 | 182 | } |
183 | 183 | |
184 | - if(is_array($list)) |
|
184 | + if (is_array($list)) |
|
185 | 185 | TPropertyAccess::set($parentObject, $property, $list); |
186 | 186 | |
187 | - if($this->_entries[$parent]['property'] === null) |
|
187 | + if ($this->_entries[$parent]['property'] === null) |
|
188 | 188 | $this->_list[] = $parentObject; |
189 | 189 | } |
190 | 190 |
@@ -66,16 +66,18 @@ discard block |
||
66 | 66 | $this->_entries[$node] = $object; |
67 | 67 | if(empty($parent)) |
68 | 68 | { |
69 | - if(isset($this->_entries[$node])) |
|
70 | - return; |
|
69 | + if(isset($this->_entries[$node])) { |
|
70 | + return; |
|
71 | + } |
|
71 | 72 | $this->_tree[$node] = []; |
72 | 73 | } |
73 | 74 | $found = $this->addNode($this->_tree, $parent, $node); |
74 | 75 | if(!$found && !empty($parent)) |
75 | 76 | { |
76 | 77 | $this->_tree[$parent] = []; |
77 | - if(!isset($this->_entries[$parent]) || $object !== '') |
|
78 | - $this->_entries[$parent] = $object; |
|
78 | + if(!isset($this->_entries[$parent]) || $object !== '') { |
|
79 | + $this->_entries[$parent] = $object; |
|
80 | + } |
|
79 | 81 | $this->addNode($this->_tree, $parent, $node); |
80 | 82 | } |
81 | 83 | } |
@@ -99,8 +101,7 @@ discard block |
||
99 | 101 | { |
100 | 102 | $found = true; |
101 | 103 | $childs[$key][$node] = []; |
102 | - } |
|
103 | - else |
|
104 | + } else |
|
104 | 105 | { |
105 | 106 | $found = $found || $this->addNode($childs[$key], $parent, $node); |
106 | 107 | } |
@@ -113,8 +114,9 @@ discard block |
||
113 | 114 | */ |
114 | 115 | public function collect() |
115 | 116 | { |
116 | - while(count($this->_tree) > 0) |
|
117 | - $this->collectChildren(null, $this->_tree); |
|
117 | + while(count($this->_tree) > 0) { |
|
118 | + $this->collectChildren(null, $this->_tree); |
|
119 | + } |
|
118 | 120 | return $this->getCollection(); |
119 | 121 | } |
120 | 122 | |
@@ -125,9 +127,10 @@ discard block |
||
125 | 127 | protected function hasChildren(&$nodes) |
126 | 128 | { |
127 | 129 | $hasChildren = false; |
128 | - foreach($nodes as $node) |
|
129 | - if(count($node) != 0) |
|
130 | + foreach($nodes as $node) { |
|
131 | + if(count($node) != 0) |
|
130 | 132 | return true; |
133 | + } |
|
131 | 134 | return $hasChildren; |
132 | 135 | } |
133 | 136 | |
@@ -147,12 +150,13 @@ discard block |
||
147 | 150 | { |
148 | 151 | $childs[] = $key; |
149 | 152 | unset($nodes[$key]); |
153 | + } else { |
|
154 | + $this->collectChildren($key, $nodes[$key]); |
|
150 | 155 | } |
151 | - else |
|
152 | - $this->collectChildren($key, $nodes[$key]); |
|
153 | 156 | } |
154 | - if(count($childs) > 0) |
|
155 | - $this->onChildNodesVisited($parent, $childs); |
|
157 | + if(count($childs) > 0) { |
|
158 | + $this->onChildNodesVisited($parent, $childs); |
|
159 | + } |
|
156 | 160 | } |
157 | 161 | |
158 | 162 | /** |
@@ -162,8 +166,9 @@ discard block |
||
162 | 166 | */ |
163 | 167 | protected function onChildNodesVisited($parent, $nodes) |
164 | 168 | { |
165 | - if(empty($parent) || empty($this->_entries[$parent])) |
|
166 | - return; |
|
169 | + if(empty($parent) || empty($this->_entries[$parent])) { |
|
170 | + return; |
|
171 | + } |
|
167 | 172 | |
168 | 173 | $parentObject = $this->_entries[$parent]['object']; |
169 | 174 | $property = $this->_entries[$nodes[0]]['property']; |
@@ -172,20 +177,23 @@ discard block |
||
172 | 177 | |
173 | 178 | foreach($nodes as $node) |
174 | 179 | { |
175 | - if($list instanceof TList) |
|
176 | - $parentObject->{$property}[] = $this->_entries[$node]['object']; |
|
177 | - elseif(is_array($list)) |
|
178 | - $list[] = $this->_entries[$node]['object']; |
|
179 | - else |
|
180 | - throw new TSqlMapExecutionException( |
|
180 | + if($list instanceof TList) { |
|
181 | + $parentObject->{$property}[] = $this->_entries[$node]['object']; |
|
182 | + } elseif(is_array($list)) { |
|
183 | + $list[] = $this->_entries[$node]['object']; |
|
184 | + } else { |
|
185 | + throw new TSqlMapExecutionException( |
|
181 | 186 | 'sqlmap_property_must_be_list'); |
187 | + } |
|
182 | 188 | } |
183 | 189 | |
184 | - if(is_array($list)) |
|
185 | - TPropertyAccess::set($parentObject, $property, $list); |
|
190 | + if(is_array($list)) { |
|
191 | + TPropertyAccess::set($parentObject, $property, $list); |
|
192 | + } |
|
186 | 193 | |
187 | - if($this->_entries[$parent]['property'] === null) |
|
188 | - $this->_list[] = $parentObject; |
|
194 | + if($this->_entries[$parent]['property'] === null) { |
|
195 | + $this->_list[] = $parentObject; |
|
196 | + } |
|
189 | 197 | } |
190 | 198 | |
191 | 199 | /** |
@@ -199,9 +207,15 @@ discard block |
||
199 | 207 | public function __sleep() |
200 | 208 | { |
201 | 209 | $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"; |
|
210 | + if (!count($this->_tree)) { |
|
211 | + $exprops[] = "\0$cn\0_tree"; |
|
212 | + } |
|
213 | + if (!count($this->_entries)) { |
|
214 | + $exprops[] = "\0$cn\0_entries"; |
|
215 | + } |
|
216 | + if (!count($this->_list)) { |
|
217 | + $exprops[] = "\0$cn\0_list"; |
|
218 | + } |
|
205 | 219 | return array_diff(parent::__sleep(), $exprops); |
206 | 220 | } |
207 | 221 | } |
208 | 222 | \ No newline at end of file |
@@ -47,9 +47,9 @@ discard block |
||
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 | - if($map === null) |
|
52 | + if ($map === null) |
|
53 | 53 | { |
54 | 54 | $map = $this->_mappedStatement->runQueryForMap( |
55 | 55 | $connection, $parameter, $sql, $keyProperty, $valueProperty, $delegate); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $sql = $this->createCommand($connection, $parameter, $skip, $max); |
74 | 74 | $key = $this->getCacheKey([clone($sql), $parameter, $skip, $max]); |
75 | 75 | $list = $this->getStatement()->getCache()->get($key); |
76 | - if($list === null) |
|
76 | + if ($list === null) |
|
77 | 77 | { |
78 | 78 | $list = $this->_mappedStatement->runQueryForList( |
79 | 79 | $connection, $parameter, $sql, $result, $delegate); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $sql = $this->createCommand($connection, $parameter); |
88 | 88 | $key = $this->getCacheKey([clone($sql), $parameter]); |
89 | 89 | $object = $this->getStatement()->getCache()->get($key); |
90 | - if($object === null) |
|
90 | + if ($object === null) |
|
91 | 91 | { |
92 | 92 | $object = $this->_mappedStatement->runQueryForObject($connection, $sql, $result); |
93 | 93 | $this->getStatement()->getCache()->set($key, $object); |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | private $_parameterNames; |
28 | 28 | private $_parameterValues; |
29 | 29 | |
30 | - public function getPreparedSql(){ return $this->_sqlString; } |
|
31 | - public function setPreparedSql($value){ $this->_sqlString = $value; } |
|
30 | + public function getPreparedSql() { return $this->_sqlString; } |
|
31 | + public function setPreparedSql($value) { $this->_sqlString = $value; } |
|
32 | 32 | |
33 | 33 | public function getParameterNames($needed = true) |
34 | 34 | { |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | return $this->_parameterNames; |
38 | 38 | } |
39 | 39 | |
40 | - public function setParameterNames($value){ $this->_parameterNames = $value; } |
|
40 | + public function setParameterNames($value) { $this->_parameterNames = $value; } |
|
41 | 41 | |
42 | 42 | public function getParameterValues($needed = true) |
43 | 43 | { |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | return $this->_parameterValues; |
47 | 47 | } |
48 | 48 | |
49 | - public function setParameterValues($value){ $this->_parameterValues = $value; } |
|
49 | + public function setParameterValues($value) { $this->_parameterValues = $value; } |
|
50 | 50 | |
51 | 51 | public function __sleep() |
52 | 52 | { |
@@ -32,8 +32,9 @@ discard block |
||
32 | 32 | |
33 | 33 | public function getParameterNames($needed = true) |
34 | 34 | { |
35 | - if (!$this->_parameterNames and $needed) |
|
36 | - $this->_parameterNames = new TList; |
|
35 | + if (!$this->_parameterNames and $needed) { |
|
36 | + $this->_parameterNames = new TList; |
|
37 | + } |
|
37 | 38 | return $this->_parameterNames; |
38 | 39 | } |
39 | 40 | |
@@ -41,8 +42,9 @@ discard block |
||
41 | 42 | |
42 | 43 | public function getParameterValues($needed = true) |
43 | 44 | { |
44 | - if (!$this->_parameterValues and $needed) |
|
45 | - $this->_parameterValues = new TMap; |
|
45 | + if (!$this->_parameterValues and $needed) { |
|
46 | + $this->_parameterValues = new TMap; |
|
47 | + } |
|
46 | 48 | return $this->_parameterValues; |
47 | 49 | } |
48 | 50 | |
@@ -51,8 +53,12 @@ discard block |
||
51 | 53 | public function __sleep() |
52 | 54 | { |
53 | 55 | $exprops = []; $cn = __CLASS__; |
54 | - if (!$this->_parameterNames or !$this->_parameterNames->getCount()) $exprops[] = "\0$cn\0_parameterNames"; |
|
55 | - if (!$this->_parameterValues or !$this->_parameterValues->getCount()) $exprops[] = "\0$cn\0_parameterValues"; |
|
56 | + if (!$this->_parameterNames or !$this->_parameterNames->getCount()) { |
|
57 | + $exprops[] = "\0$cn\0_parameterNames"; |
|
58 | + } |
|
59 | + if (!$this->_parameterValues or !$this->_parameterValues->getCount()) { |
|
60 | + $exprops[] = "\0$cn\0_parameterValues"; |
|
61 | + } |
|
56 | 62 | return array_diff(parent::__sleep(), $exprops); |
57 | 63 | } |
58 | 64 | } |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | $connection->setActive(true); |
35 | 35 | $sql = $prepared->getPreparedSql(); |
36 | 36 | |
37 | - if($sqlText instanceof TSimpleDynamicSql) |
|
37 | + if ($sqlText instanceof TSimpleDynamicSql) |
|
38 | 38 | $sql = $sqlText->replaceDynamicParameter($sql, $parameterObject); |
39 | 39 | |
40 | - if($max !== null || $skip !== null) |
|
40 | + if ($max !== null || $skip !== null) |
|
41 | 41 | { |
42 | 42 | $builder = TDbMetaData::getInstance($connection)->createCommandBuilder(); |
43 | 43 | $sql = $builder->applyLimitOffset($sql, $max, $skip); |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | //$parameters = $prepared->getParameterValues(); |
55 | 55 | $registry = $manager->getTypeHandlers(); |
56 | 56 | if ($properties) |
57 | - for($i = 0, $k = $properties->getCount(); $i < $k; $i++) |
|
57 | + for ($i = 0, $k = $properties->getCount(); $i < $k; $i++) |
|
58 | 58 | { |
59 | 59 | $property = $statement->parameterMap()->getProperty($i); |
60 | 60 | $value = $statement->parameterMap()->getPropertyValue($registry, $property, $parameterObject); |
61 | 61 | $dbType = $property->getDbType(); |
62 | - if($dbType == '') //relies on PHP lax comparison |
|
62 | + if ($dbType == '') //relies on PHP lax comparison |
|
63 | 63 | $command->bindValue($i + 1, $value, TDbCommandBuilder::getPdoType($value)); |
64 | - elseif(strpos($dbType, 'PDO::') === 0) |
|
64 | + elseif (strpos($dbType, 'PDO::') === 0) |
|
65 | 65 | $command->bindValue($i + 1, $value, constant($property->getDbType())); //assumes PDO types, e.g. PDO::PARAM_INT |
66 | 66 | else |
67 | 67 | $command->bindValue($i + 1, $value); |
@@ -34,8 +34,9 @@ discard block |
||
34 | 34 | $connection->setActive(true); |
35 | 35 | $sql = $prepared->getPreparedSql(); |
36 | 36 | |
37 | - if($sqlText instanceof TSimpleDynamicSql) |
|
38 | - $sql = $sqlText->replaceDynamicParameter($sql, $parameterObject); |
|
37 | + if($sqlText instanceof TSimpleDynamicSql) { |
|
38 | + $sql = $sqlText->replaceDynamicParameter($sql, $parameterObject); |
|
39 | + } |
|
39 | 40 | |
40 | 41 | if($max !== null || $skip !== null) |
41 | 42 | { |
@@ -53,18 +54,24 @@ discard block |
||
53 | 54 | $properties = $prepared->getParameterNames(false); |
54 | 55 | //$parameters = $prepared->getParameterValues(); |
55 | 56 | $registry = $manager->getTypeHandlers(); |
56 | - if ($properties) |
|
57 | - for($i = 0, $k = $properties->getCount(); $i < $k; $i++) |
|
57 | + if ($properties) { |
|
58 | + for($i = 0, $k = $properties->getCount(); |
|
59 | + } |
|
60 | + $i < $k; $i++) |
|
58 | 61 | { |
59 | 62 | $property = $statement->parameterMap()->getProperty($i); |
60 | 63 | $value = $statement->parameterMap()->getPropertyValue($registry, $property, $parameterObject); |
61 | 64 | $dbType = $property->getDbType(); |
62 | - if($dbType == '') //relies on PHP lax comparison |
|
65 | + if($dbType == '') { |
|
66 | + //relies on PHP lax comparison |
|
63 | 67 | $command->bindValue($i + 1, $value, TDbCommandBuilder::getPdoType($value)); |
64 | - elseif(strpos($dbType, 'PDO::') === 0) |
|
65 | - $command->bindValue($i + 1, $value, constant($property->getDbType())); //assumes PDO types, e.g. PDO::PARAM_INT |
|
66 | - else |
|
67 | - $command->bindValue($i + 1, $value); |
|
68 | + } elseif(strpos($dbType, 'PDO::') === 0) { |
|
69 | + $command->bindValue($i + 1, $value, constant($property->getDbType())); |
|
70 | + } |
|
71 | + //assumes PDO types, e.g. PDO::PARAM_INT |
|
72 | + else { |
|
73 | + $command->bindValue($i + 1, $value); |
|
74 | + } |
|
68 | 75 | } |
69 | 76 | } |
70 | 77 | } |