Completed
Push — scrutinizer ( c2ef4a )
by Fabio
21:50
created
framework/Data/SqlMap/Statements/TMappedStatement.php 3 patches
Doc Comments   +14 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	}
85 85
 
86 86
 	/**
87
-	 * @return TSqlMapper The SqlMap used by this MappedStatement
87
+	 * @return TSqlMapManager The SqlMap used by this MappedStatement
88 88
 	 */
89 89
 	public function getManager()
90 90
 	{
@@ -469,6 +469,7 @@  discard block
 block discarded – undo
469 469
 	 * @param IDbConnection database connection
470 470
 	 * @param mixed insert statement parameter
471 471
 	 * @param TSqlMapSelectKey select key statement
472
+	 * @param TSqlMapSelectKey $selectKey
472 473
 	 * @return string last insert ID.
473 474
 	 */
474 475
 	protected function executeSelectKey($connection, $parameter, $selectKey)
@@ -569,6 +570,7 @@  discard block
 block discarded – undo
569 570
 	 * @param string result object class name
570 571
 	 * @param array a result set row retrieved from the database
571 572
 	 * @param object the result object, will create if necessary.
573
+	 * @param string $resultClass
572 574
 	 * @return object result object filled with data
573 575
 	 */
574 576
 	protected function fillResultClass($resultClass, $row, $resultObject)
@@ -591,6 +593,7 @@  discard block
 block discarded – undo
591 593
 	 * Apply the result to a TList or an array.
592 594
 	 * @param array a result set row retrieved from the database
593 595
 	 * @param object result object, array or list
596
+	 * @param ArrayAccess $resultObject
594 597
 	 * @return object result filled with data.
595 598
 	 */
596 599
 	protected function fillResultArrayList($row, $resultObject)
@@ -633,6 +636,7 @@  discard block
 block discarded – undo
633 636
 	 * @param string result map name.
634 637
 	 * @param array a result set row retrieved from the database
635 638
 	 * @param object result object to fill, will create new instances if required.
639
+	 * @param string $parentGroup
636 640
 	 * @return object result object filled with data.
637 641
 	 */
638 642
 	protected function fillResultMap($resultMapName, $row, $parentGroup=null, &$resultObject=null)
@@ -772,6 +776,7 @@  discard block
 block discarded – undo
772 776
 	 * Converts the first array value to scalar value of given type.
773 777
 	 * @param array list of results
774 778
 	 * @param string scalar type.
779
+	 * @param string $type
775 780
 	 * @return mixed scalar value.
776 781
 	 */
777 782
 	protected function getScalarResult($result, $type)
@@ -961,6 +966,10 @@  discard block
 block discarded – undo
961 966
 	public function setKeys($value){ $this->_keys = $value; }
962 967
 
963 968
 	public function getMethod(){ return $this->_method; }
969
+
970
+	/**
971
+	 * @param integer $value
972
+	 */
964 973
 	public function setMethod($value){ $this->_method = $value; }
965 974
 }
966 975
 
@@ -1003,6 +1012,7 @@  discard block
 block discarded – undo
1003 1012
 	 * @param string parent node id
1004 1013
 	 * @param string new node id
1005 1014
 	 * @param mixed node value
1015
+	 * @param string $node
1006 1016
 	 */
1007 1017
 	public function add($parent, $node, $object='')
1008 1018
 	{
@@ -1168,6 +1178,9 @@  discard block
 block discarded – undo
1168 1178
 	private $_parameterObject;
1169 1179
 	private $_list;
1170 1180
 
1181
+	/**
1182
+	 * @param ArrayAccess $list
1183
+	 */
1171 1184
 	public function __construct($result, $parameter, &$list)
1172 1185
 	{
1173 1186
 		$this->_resultObject = $result;
Please login to merge, or discard this patch.
Spacing   +147 added lines, -150 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	/**
40 40
 	 * @var TPostSelectBinding[] post select statement queue.
41 41
 	 */
42
-	private $_selectQueue=array();
42
+	private $_selectQueue = array();
43 43
 
44 44
 	/**
45 45
 	 * @var boolean true when data is mapped to a particular row.
@@ -161,11 +161,11 @@  discard block
 block discarded – undo
161 161
 	 */
162 162
 	protected function executeSQLQueryLimit($connection, $command, $max, $skip)
163 163
 	{
164
-		if($max>-1 || $skip > -1)
164
+		if ($max > -1 || $skip > -1)
165 165
 		{
166
-			$maxStr=$max>0?' LIMIT '.$max:'';
167
-			$skipStr=$skip>0?' OFFSET '.$skip:'';
168
-			$command->setText($command->getText().$maxStr.$skipStr);
166
+			$maxStr = $max > 0 ? ' LIMIT ' . $max : '';
167
+			$skipStr = $skip > 0 ? ' OFFSET ' . $skip : '';
168
+			$command->setText($command->getText() . $maxStr . $skipStr);
169 169
 		}
170 170
 		$connection->setActive(true);
171 171
 		return $command->query();
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 	 * @param callback row delegate handler
200 200
 	 * @see executeQueryForList()
201 201
 	 */
202
-	public function executeQueryForList($connection, $parameter, $result=null, $skip=-1, $max=-1, $delegate=null)
202
+	public function executeQueryForList($connection, $parameter, $result = null, $skip = -1, $max = -1, $delegate = null)
203 203
 	{
204
-		$sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter,$skip,$max);
204
+		$sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter, $skip, $max);
205 205
 		return $this->runQueryForList($connection, $parameter, $sql, $result, $delegate);
206 206
 	}
207 207
 
@@ -221,17 +221,16 @@  discard block
 block discarded – undo
221 221
 	 * @return array a list of result objects
222 222
 	 * @see executeQueryForList()
223 223
 	 */
224
-	public function runQueryForList($connection, $parameter, $sql, $result, $delegate=null)
224
+	public function runQueryForList($connection, $parameter, $sql, $result, $delegate = null)
225 225
 	{
226
-		$registry=$this->getManager()->getTypeHandlers();
227
-		$list = $result instanceof ArrayAccess ? $result :
228
-							$this->_statement->createInstanceOfListClass($registry);
226
+		$registry = $this->getManager()->getTypeHandlers();
227
+		$list = $result instanceof ArrayAccess ? $result : $this->_statement->createInstanceOfListClass($registry);
229 228
 		$connection->setActive(true);
230 229
 		$reader = $sql->query();
231 230
 		//$reader = $this->executeSQLQueryLimit($connection, $sql, $max, $skip);
232
-		if($delegate!==null)
231
+		if ($delegate !== null)
233 232
 		{
234
-			foreach($reader as $row)
233
+			foreach ($reader as $row)
235 234
 			{
236 235
 				$obj = $this->applyResultMap($row);
237 236
 				$param = new TResultSetListItemParameter($obj, $parameter, $list);
@@ -241,14 +240,14 @@  discard block
 block discarded – undo
241 240
 		else
242 241
 		{
243 242
 			//var_dump($sql,$parameter);
244
-			foreach($reader as $row)
243
+			foreach ($reader as $row)
245 244
 			{
246 245
 //				var_dump($row);
247 246
 				$list[] = $this->applyResultMap($row);
248 247
 			}
249 248
 		}
250 249
 
251
-		if(!$this->_groupBy->isEmpty())
250
+		if (!$this->_groupBy->isEmpty())
252 251
 		{
253 252
 			$list = $this->_groupBy->collect();
254 253
 			$this->initialGroupByResults();
@@ -272,7 +271,7 @@  discard block
 block discarded – undo
272 271
 	 * @param callback row delegate handler
273 272
 	 * @return array An array of object containing the rows keyed by keyProperty.
274 273
 	 */
275
-	public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty=null,  $skip=-1, $max=-1, $delegate=null)
274
+	public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty = null, $skip = -1, $max = -1, $delegate = null)
276 275
 	{
277 276
 		$sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter, $skip, $max);
278 277
 		return $this->runQueryForMap($connection, $parameter, $sql, $keyProperty, $valueProperty, $delegate);
@@ -296,21 +295,20 @@  discard block
 block discarded – undo
296 295
 	 * @return array An array of object containing the rows keyed by keyProperty.
297 296
 	 * @see executeQueryForMap()
298 297
 	 */
299
-	public function runQueryForMap($connection, $parameter, $command, $keyProperty, $valueProperty=null, $delegate=null)
298
+	public function runQueryForMap($connection, $parameter, $command, $keyProperty, $valueProperty = null, $delegate = null)
300 299
 	{
301 300
 		$map = array();
302 301
 		//$recordSet = $this->executeSQLQuery($connection, $sql);
303 302
 		$connection->setActive(true);
304 303
 		$reader = $command->query();
305
-		if($delegate!==null)
304
+		if ($delegate !== null)
306 305
 		{
307 306
 			//while($row = $recordSet->fetchRow())
308
-			foreach($reader as $row)
307
+			foreach ($reader as $row)
309 308
 			{
310 309
 				$obj = $this->applyResultMap($row);
311 310
 				$key = TPropertyAccess::get($obj, $keyProperty);
312
-				$value = ($valueProperty===null) ? $obj :
313
-							TPropertyAccess::get($obj, $valueProperty);
311
+				$value = ($valueProperty === null) ? $obj : TPropertyAccess::get($obj, $valueProperty);
314 312
 				$param = new TResultSetMapItemParameter($key, $value, $parameter, $map);
315 313
 				$this->raiseRowDelegate($delegate, $param);
316 314
 			}
@@ -318,12 +316,11 @@  discard block
 block discarded – undo
318 316
 		else
319 317
 		{
320 318
 			//while($row = $recordSet->fetchRow())
321
-			foreach($reader as $row)
319
+			foreach ($reader as $row)
322 320
 			{
323 321
 				$obj = $this->applyResultMap($row);
324 322
 				$key = TPropertyAccess::get($obj, $keyProperty);
325
-				$map[$key] = ($valueProperty===null) ? $obj :
326
-								TPropertyAccess::get($obj, $valueProperty);
323
+				$map[$key] = ($valueProperty === null) ? $obj : TPropertyAccess::get($obj, $valueProperty);
327 324
 			}
328 325
 		}
329 326
 		$this->onExecuteQuery($command);
@@ -338,24 +335,24 @@  discard block
 block discarded – undo
338 335
 	 */
339 336
 	protected function raiseRowDelegate($handler, $param)
340 337
 	{
341
-		if(is_string($handler))
338
+		if (is_string($handler))
342 339
 		{
343
-			call_user_func($handler,$this,$param);
340
+			call_user_func($handler, $this, $param);
344 341
 		}
345
-		else if(is_callable($handler,true))
342
+		else if (is_callable($handler, true))
346 343
 		{
347 344
 			// an array: 0 - object, 1 - method name/path
348
-			list($object,$method)=$handler;
349
-			if(is_string($object))	// static method call
350
-				call_user_func($handler,$this,$param);
345
+			list($object, $method) = $handler;
346
+			if (is_string($object))	// static method call
347
+				call_user_func($handler, $this, $param);
351 348
 			else
352 349
 			{
353
-				if(($pos=strrpos($method,'.'))!==false)
350
+				if (($pos = strrpos($method, '.')) !== false)
354 351
 				{
355
-					$object=$this->getSubProperty(substr($method,0,$pos));
356
-					$method=substr($method,$pos+1);
352
+					$object = $this->getSubProperty(substr($method, 0, $pos));
353
+					$method = substr($method, $pos + 1);
357 354
 				}
358
-				$object->$method($this,$param);
355
+				$object->$method($this, $param);
359 356
 			}
360 357
 		}
361 358
 		else
@@ -370,7 +367,7 @@  discard block
 block discarded – undo
370 367
 	 * @param mixed The result object.
371 368
 	 * @return ${return}
372 369
 	 */
373
-	public function executeQueryForObject($connection, $parameter, $result=null)
370
+	public function executeQueryForObject($connection, $parameter, $result = null)
374 371
 	{
375 372
 		$sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter);
376 373
 		return $this->runQueryForObject($connection, $sql, $result);
@@ -393,10 +390,10 @@  discard block
 block discarded – undo
393 390
 	{
394 391
 		$object = null;
395 392
 		$connection->setActive(true);
396
-		foreach($command->query() as $row)
393
+		foreach ($command->query() as $row)
397 394
 			$object = $this->applyResultMap($row, $result);
398 395
 
399
-		if(!$this->_groupBy->isEmpty())
396
+		if (!$this->_groupBy->isEmpty())
400 397
 		{
401 398
 			$list = $this->_groupBy->collect();
402 399
 			$this->initialGroupByResults();
@@ -424,7 +421,7 @@  discard block
 block discarded – undo
424 421
 //		var_dump($command,$parameter);
425 422
 		$result = $command->execute();
426 423
 
427
-		if($generatedKey===null)
424
+		if ($generatedKey === null)
428 425
 			$generatedKey = $this->getPostGeneratedSelectKey($connection, $parameter);
429 426
 
430 427
 		$this->executePostSelect($connection);
@@ -440,10 +437,10 @@  discard block
 block discarded – undo
440 437
 	 */
441 438
 	protected function getPreGeneratedSelectKey($connection, $parameter)
442 439
 	{
443
-		if($this->_statement instanceof TSqlMapInsert)
440
+		if ($this->_statement instanceof TSqlMapInsert)
444 441
 		{
445 442
 			$selectKey = $this->_statement->getSelectKey();
446
-			if(($selectKey!==null) && !$selectKey->getIsAfter())
443
+			if (($selectKey !== null) && !$selectKey->getIsAfter())
447 444
 				return $this->executeSelectKey($connection, $parameter, $selectKey);
448 445
 		}
449 446
 	}
@@ -456,10 +453,10 @@  discard block
 block discarded – undo
456 453
 	 */
457 454
 	protected function getPostGeneratedSelectKey($connection, $parameter)
458 455
 	{
459
-		if($this->_statement instanceof TSqlMapInsert)
456
+		if ($this->_statement instanceof TSqlMapInsert)
460 457
 		{
461 458
 			$selectKey = $this->_statement->getSelectKey();
462
-			if(($selectKey!==null) && $selectKey->getIsAfter())
459
+			if (($selectKey !== null) && $selectKey->getIsAfter())
463 460
 				return $this->executeSelectKey($connection, $parameter, $selectKey);
464 461
 		}
465 462
 	}
@@ -476,7 +473,7 @@  discard block
 block discarded – undo
476 473
 		$mappedStatement = $this->getManager()->getMappedStatement($selectKey->getID());
477 474
 		$generatedKey = $mappedStatement->executeQueryForObject(
478 475
 									$connection, $parameter, null);
479
-		if(strlen($prop = $selectKey->getProperty()) > 0)
476
+		if (strlen($prop = $selectKey->getProperty()) > 0)
480 477
 				TPropertyAccess::set($parameter, $prop, $generatedKey);
481 478
 		return $generatedKey;
482 479
 	}
@@ -490,7 +487,7 @@  discard block
 block discarded – undo
490 487
 	 */
491 488
 	public function executeUpdate($connection, $parameter)
492 489
 	{
493
-		$sql = $this->_command->create($this->getManager(),$connection, $this->_statement, $parameter);
490
+		$sql = $this->_command->create($this->getManager(), $connection, $this->_statement, $parameter);
494 491
 		$affectedRows = $sql->execute();
495 492
 		//$this->executeSQLQuery($connection, $sql);
496 493
 		$this->executePostSelect($connection);
@@ -504,7 +501,7 @@  discard block
 block discarded – undo
504 501
 	 */
505 502
 	protected function executePostSelect($connection)
506 503
 	{
507
-		while(count($this->_selectQueue))
504
+		while (count($this->_selectQueue))
508 505
 		{
509 506
 			$postSelect = array_shift($this->_selectQueue);
510 507
 			$method = $postSelect->getMethod();
@@ -513,15 +510,15 @@  discard block
 block discarded – undo
513 510
 			$keys = $postSelect->getKeys();
514 511
 			$resultObject = $postSelect->getResultObject();
515 512
 
516
-			if($method == self::QUERY_FOR_LIST || $method == self::QUERY_FOR_ARRAY)
513
+			if ($method == self::QUERY_FOR_LIST || $method == self::QUERY_FOR_ARRAY)
517 514
 			{
518 515
 				$values = $statement->executeQueryForList($connection, $keys, null);
519 516
 
520
-				if($method == self::QUERY_FOR_ARRAY)
517
+				if ($method == self::QUERY_FOR_ARRAY)
521 518
 					$values = $values->toArray();
522 519
 				TPropertyAccess::set($resultObject, $property, $values);
523 520
 			}
524
-			else if($method == self::QUERY_FOR_OBJECT)
521
+			else if ($method == self::QUERY_FOR_OBJECT)
525 522
 			{
526 523
 				$value = $statement->executeQueryForObject($connection, $keys, null);
527 524
 				TPropertyAccess::set($resultObject, $property, $value);
@@ -544,23 +541,23 @@  discard block
 block discarded – undo
544 541
 	 * @param object the result object, will create if necessary.
545 542
 	 * @return object the result filled with data, null if not filled.
546 543
 	 */
547
-	protected function applyResultMap($row, &$resultObject=null)
544
+	protected function applyResultMap($row, &$resultObject = null)
548 545
 	{
549
-		if($row === false) return null;
546
+		if ($row === false) return null;
550 547
 
551 548
 		$resultMapName = $this->_statement->getResultMap();
552 549
 		$resultClass = $this->_statement->getResultClass();
553 550
 
554
-		$obj=null;
555
-		if($this->getManager()->getResultMaps()->contains($resultMapName))
551
+		$obj = null;
552
+		if ($this->getManager()->getResultMaps()->contains($resultMapName))
556 553
 			$obj = $this->fillResultMap($resultMapName, $row, null, $resultObject);
557
-		else if(strlen($resultClass) > 0)
554
+		else if (strlen($resultClass) > 0)
558 555
 			$obj = $this->fillResultClass($resultClass, $row, $resultObject);
559 556
 		else
560 557
 			$obj = $this->fillDefaultResultMap(null, $row, $resultObject);
561
-		if(class_exists('TActiveRecord',false) && $obj instanceof TActiveRecord)
558
+		if (class_exists('TActiveRecord', false) && $obj instanceof TActiveRecord)
562 559
 			//Create a new clean active record.
563
-			$obj=TActiveRecord::createRecord(get_class($obj),$obj);
560
+			$obj = TActiveRecord::createRecord(get_class($obj), $obj);
564 561
 		return $obj;
565 562
 	}
566 563
 
@@ -573,15 +570,15 @@  discard block
 block discarded – undo
573 570
 	 */
574 571
 	protected function fillResultClass($resultClass, $row, $resultObject)
575 572
 	{
576
-		if($resultObject===null)
573
+		if ($resultObject === null)
577 574
 		{
578 575
 			$registry = $this->getManager()->getTypeHandlers();
579
-			$resultObject = $this->_statement->createInstanceOfResultClass($registry,$row);
576
+			$resultObject = $this->_statement->createInstanceOfResultClass($registry, $row);
580 577
 		}
581 578
 
582
-		if($resultObject instanceOf ArrayAccess)
579
+		if ($resultObject instanceOf ArrayAccess)
583 580
 			return $this->fillResultArrayList($row, $resultObject);
584
-		else if(is_object($resultObject))
581
+		else if (is_object($resultObject))
585 582
 			return $this->fillResultObjectProperty($row, $resultObject);
586 583
 		else
587 584
 			return $this->fillDefaultResultMap(null, $row, $resultObject);
@@ -595,11 +592,11 @@  discard block
 block discarded – undo
595 592
 	 */
596 593
 	protected function fillResultArrayList($row, $resultObject)
597 594
 	{
598
-		if($resultObject instanceof TList)
599
-			foreach($row as $v)
595
+		if ($resultObject instanceof TList)
596
+			foreach ($row as $v)
600 597
 				$resultObject[] = $v;
601 598
 		else
602
-			foreach($row as $k => $v)
599
+			foreach ($row as $k => $v)
603 600
 				$resultObject[$k] = $v;
604 601
 		return $resultObject;
605 602
 	}
@@ -613,17 +610,17 @@  discard block
 block discarded – undo
613 610
 	protected function fillResultObjectProperty($row, $resultObject)
614 611
 	{
615 612
 		$index = 0;
616
-		$registry=$this->getManager()->getTypeHandlers();
617
-		foreach($row as $k=>$v)
613
+		$registry = $this->getManager()->getTypeHandlers();
614
+		foreach ($row as $k=>$v)
618 615
 		{
619 616
 			$property = new TResultProperty;
620
-			if(is_string($k) && strlen($k) > 0)
617
+			if (is_string($k) && strlen($k) > 0)
621 618
 				$property->setColumn($k);
622 619
 			$property->setColumnIndex(++$index);
623
-			$type = gettype(TPropertyAccess::get($resultObject,$k));
620
+			$type = gettype(TPropertyAccess::get($resultObject, $k));
624 621
 			$property->setType($type);
625
-			$value = $property->getPropertyValue($registry,$row);
626
-			TPropertyAccess::set($resultObject, $k,$value);
622
+			$value = $property->getPropertyValue($registry, $row);
623
+			TPropertyAccess::set($resultObject, $k, $value);
627 624
 		}
628 625
 		return $resultObject;
629 626
 	}
@@ -635,21 +632,21 @@  discard block
 block discarded – undo
635 632
 	 * @param object result object to fill, will create new instances if required.
636 633
 	 * @return object result object filled with data.
637 634
 	 */
638
-	protected function fillResultMap($resultMapName, $row, $parentGroup=null, &$resultObject=null)
635
+	protected function fillResultMap($resultMapName, $row, $parentGroup = null, &$resultObject = null)
639 636
 	{
640 637
 		$resultMap = $this->getManager()->getResultMap($resultMapName);
641 638
 		$registry = $this->getManager()->getTypeHandlers();
642
-		$resultMap = $resultMap->resolveSubMap($registry,$row);
639
+		$resultMap = $resultMap->resolveSubMap($registry, $row);
643 640
 
644
-		if($resultObject===null)
641
+		if ($resultObject === null)
645 642
 			$resultObject = $resultMap->createInstanceOfResult($registry);
646 643
 
647
-		if(is_object($resultObject))
644
+		if (is_object($resultObject))
648 645
 		{
649
-			if(strlen($resultMap->getGroupBy()) > 0)
646
+			if (strlen($resultMap->getGroupBy()) > 0)
650 647
 				return $this->addResultMapGroupBy($resultMap, $row, $parentGroup, $resultObject);
651 648
 			else
652
-				foreach($resultMap->getColumns() as $property)
649
+				foreach ($resultMap->getColumns() as $property)
653 650
 					$this->setObjectProperty($resultMap, $property, $row, $resultObject);
654 651
 		}
655 652
 		else
@@ -671,26 +668,26 @@  discard block
 block discarded – undo
671 668
 	{
672 669
 		$group = $this->getResultMapGroupKey($resultMap, $row);
673 670
 
674
-		if(empty($parent))
671
+		if (empty($parent))
675 672
 		{
676 673
 			$rootObject = array('object'=>$resultObject, 'property' => null);
677 674
 			$this->_groupBy->add(null, $group, $rootObject);
678 675
 		}
679 676
 
680
-		foreach($resultMap->getColumns() as $property)
677
+		foreach ($resultMap->getColumns() as $property)
681 678
 		{
682 679
 			//set properties.
683 680
 			$this->setObjectProperty($resultMap, $property, $row, $resultObject);
684 681
 			$nested = $property->getResultMapping();
685 682
 
686 683
 			//nested property
687
-			if($this->getManager()->getResultMaps()->contains($nested))
684
+			if ($this->getManager()->getResultMaps()->contains($nested))
688 685
 			{
689 686
 				$nestedMap = $this->getManager()->getResultMap($nested);
690 687
 				$groupKey = $this->getResultMapGroupKey($nestedMap, $row);
691 688
 
692 689
 				//add the node reference first
693
-				if(empty($parent))
690
+				if (empty($parent))
694 691
 					$this->_groupBy->add($group, $groupKey, '');
695 692
 
696 693
 				//get the nested result mapping value
@@ -698,7 +695,7 @@  discard block
 block discarded – undo
698 695
 
699 696
 				//add it to the object tree graph
700 697
 				$groupObject = array('object'=>$value, 'property' => $property->getProperty());
701
-				if(empty($parent))
698
+				if (empty($parent))
702 699
 					$this->_groupBy->add($group, $groupKey, $groupObject);
703 700
 				else
704 701
 					$this->_groupBy->add($parent, $groupKey, $groupObject);
@@ -716,10 +713,10 @@  discard block
 block discarded – undo
716 713
 	protected function getResultMapGroupKey($resultMap, $row)
717 714
 	{
718 715
 		$groupBy = $resultMap->getGroupBy();
719
-		if(isset($row[$groupBy]))
720
-			return $resultMap->getID().$row[$groupBy];
716
+		if (isset($row[$groupBy]))
717
+			return $resultMap->getID() . $row[$groupBy];
721 718
 		else
722
-			return $resultMap->getID().crc32(serialize($row));
719
+			return $resultMap->getID() . crc32(serialize($row));
723 720
 	}
724 721
 
725 722
 	/**
@@ -732,16 +729,16 @@  discard block
 block discarded – undo
732 729
 	 */
733 730
 	protected function fillDefaultResultMap($resultMap, $row, $resultObject)
734 731
 	{
735
-		if($resultObject===null)
736
-			$resultObject='';
732
+		if ($resultObject === null)
733
+			$resultObject = '';
737 734
 
738
-		if($resultMap!==null)
735
+		if ($resultMap !== null)
739 736
 			$result = $this->fillArrayResultMap($resultMap, $row, $resultObject);
740 737
 		else
741 738
 			$result = $row;
742 739
 
743 740
 		//if scalar result types
744
-		if(count($result) == 1 && ($type = gettype($resultObject))!= 'array')
741
+		if (count($result) == 1 && ($type = gettype($resultObject)) != 'array')
745 742
 			return $this->getScalarResult($result, $type);
746 743
 		else
747 744
 			return $result;
@@ -757,13 +754,13 @@  discard block
 block discarded – undo
757 754
 	protected function fillArrayResultMap($resultMap, $row, $resultObject)
758 755
 	{
759 756
 		$result = array();
760
-		$registry=$this->getManager()->getTypeHandlers();
761
-		foreach($resultMap->getColumns() as $column)
757
+		$registry = $this->getManager()->getTypeHandlers();
758
+		foreach ($resultMap->getColumns() as $column)
762 759
 		{
763
-			if(($column->getType()===null)
764
-				&& ($resultObject!==null) && !is_object($resultObject))
760
+			if (($column->getType() === null)
761
+				&& ($resultObject !== null) && !is_object($resultObject))
765 762
 			$column->setType(gettype($resultObject));
766
-			$result[$column->getProperty()] = $column->getPropertyValue($registry,$row);
763
+			$result[$column->getProperty()] = $column->getPropertyValue($registry, $row);
767 764
 		}
768 765
 		return $result;
769 766
 	}
@@ -793,26 +790,26 @@  discard block
 block discarded – undo
793 790
 		$select = $property->getSelect();
794 791
 		$key = $property->getProperty();
795 792
 		$nested = $property->getNestedResultMap();
796
-		$registry=$this->getManager()->getTypeHandlers();
797
-		if($key === '')
793
+		$registry = $this->getManager()->getTypeHandlers();
794
+		if ($key === '')
798 795
 		{
799
-			$resultObject = $property->getPropertyValue($registry,$row);
796
+			$resultObject = $property->getPropertyValue($registry, $row);
800 797
 		}
801
-		else if(strlen($select) == 0 && ($nested===null))
798
+		else if (strlen($select) == 0 && ($nested === null))
802 799
 		{
803
-			$value = $property->getPropertyValue($registry,$row);
800
+			$value = $property->getPropertyValue($registry, $row);
804 801
 
805 802
 			$this->_IsRowDataFound = $this->_IsRowDataFound || ($value != null);
806
-			if(is_array($resultObject) || is_object($resultObject))
803
+			if (is_array($resultObject) || is_object($resultObject))
807 804
 				TPropertyAccess::set($resultObject, $key, $value);
808 805
 			else
809 806
 				$resultObject = $value;
810 807
 		}
811
-		else if($nested!==null)
808
+		else if ($nested !== null)
812 809
 		{
813
-			if($property->instanceOfListType($resultObject) || $property->instanceOfArrayType($resultObject))
810
+			if ($property->instanceOfListType($resultObject) || $property->instanceOfArrayType($resultObject))
814 811
 			{
815
-				if(strlen($resultMap->getGroupBy()) <= 0)
812
+				if (strlen($resultMap->getGroupBy()) <= 0)
816 813
 					throw new TSqlMapExecutionException(
817 814
 						'sqlmap_non_groupby_array_list_type', $resultMap->getID(),
818 815
 						get_class($resultObject), $key);
@@ -820,7 +817,7 @@  discard block
 block discarded – undo
820 817
 			else
821 818
 			{
822 819
 				$obj = $nested->createInstanceOfResult($this->getManager()->getTypeHandlers());
823
-				if($this->fillPropertyWithResultMap($nested, $row, $obj) == false)
820
+				if ($this->fillPropertyWithResultMap($nested, $row, $obj) == false)
824 821
 					$obj = null;
825 822
 				TPropertyAccess::set($resultObject, $key, $obj);
826 823
 			}
@@ -849,10 +846,10 @@  discard block
 block discarded – undo
849 846
 		$postSelect->setResultProperty($property);
850 847
 		$postSelect->setKeys($key);
851 848
 
852
-		if($property->instanceOfListType($resultObject))
849
+		if ($property->instanceOfListType($resultObject))
853 850
 		{
854 851
 			$values = null;
855
-			if($property->getLazyLoad())
852
+			if ($property->getLazyLoad())
856 853
 			{
857 854
 				$values = TLazyLoadList::newInstance($statement, $key,
858 855
 								$resultObject, $property->getProperty());
@@ -861,12 +858,12 @@  discard block
 block discarded – undo
861 858
 			else
862 859
 				$postSelect->setMethod(self::QUERY_FOR_LIST);
863 860
 		}
864
-		else if($property->instanceOfArrayType($resultObject))
861
+		else if ($property->instanceOfArrayType($resultObject))
865 862
 			$postSelect->setMethod(self::QUERY_FOR_ARRAY);
866 863
 		else
867 864
 			$postSelect->setMethod(self::QUERY_FOR_OBJECT);
868 865
 
869
-		if(!$property->getLazyLoad())
866
+		if (!$property->getLazyLoad())
870 867
 			$this->_selectQueue[] = $postSelect;
871 868
 	}
872 869
 
@@ -877,23 +874,23 @@  discard block
 block discarded – undo
877 874
 	 * @param array current row data.
878 875
 	 * @return array list of primary key values.
879 876
 	 */
880
-	protected function getPostSelectKeys($resultMap, $property,$row)
877
+	protected function getPostSelectKeys($resultMap, $property, $row)
881 878
 	{
882 879
 		$value = $property->getColumn();
883
-		if(is_int(strpos($value.',',0)) || is_int(strpos($value, '=',0)))
880
+		if (is_int(strpos($value . ',', 0)) || is_int(strpos($value, '=', 0)))
884 881
 		{
885 882
 			$keys = array();
886
-			foreach(explode(',', $value) as $entry)
883
+			foreach (explode(',', $value) as $entry)
887 884
 			{
888
-				$pair =explode('=',$entry);
885
+				$pair = explode('=', $entry);
889 886
 				$keys[trim($pair[0])] = $row[trim($pair[1])];
890 887
 			}
891 888
 			return $keys;
892 889
 		}
893 890
 		else
894 891
 		{
895
-			$registry=$this->getManager()->getTypeHandlers();
896
-			return $property->getPropertyValue($registry,$row);
892
+			$registry = $this->getManager()->getTypeHandlers();
893
+			return $property->getPropertyValue($registry, $row);
897 894
 		}
898 895
 	}
899 896
 
@@ -907,7 +904,7 @@  discard block
 block discarded – undo
907 904
 	protected function fillPropertyWithResultMap($resultMap, $row, &$resultObject)
908 905
 	{
909 906
 		$dataFound = false;
910
-		foreach($resultMap->getColumns() as $property)
907
+		foreach ($resultMap->getColumns() as $property)
911 908
 		{
912 909
 			$this->_IsRowDataFound = false;
913 910
 			$this->setObjectProperty($resultMap, $property, $row, $resultObject);
@@ -929,7 +926,7 @@  discard block
 block discarded – undo
929 926
 		if (!count($this->_selectQueue)) $exprops[] = "\0$cn\0_selectQueue";
930 927
 		if (is_null($this->_groupBy)) $exprops[] = "\0$cn\0_groupBy";
931 928
 		if (!$this->_IsRowDataFound) $exprops[] = "\0$cn\0_IsRowDataFound";
932
-		return array_diff(parent::__sleep(),$exprops);
929
+		return array_diff(parent::__sleep(), $exprops);
933 930
 	}
934 931
 }
935 932
 
@@ -942,26 +939,26 @@  discard block
 block discarded – undo
942 939
  */
943 940
 class TPostSelectBinding
944 941
 {
945
-	private $_statement=null;
946
-	private $_property=null;
947
-	private $_resultObject=null;
948
-	private $_keys=null;
949
-	private $_method=TMappedStatement::QUERY_FOR_LIST;
942
+	private $_statement = null;
943
+	private $_property = null;
944
+	private $_resultObject = null;
945
+	private $_keys = null;
946
+	private $_method = TMappedStatement::QUERY_FOR_LIST;
950 947
 
951
-	public function getStatement(){ return $this->_statement; }
952
-	public function setStatement($value){ $this->_statement = $value; }
948
+	public function getStatement() { return $this->_statement; }
949
+	public function setStatement($value) { $this->_statement = $value; }
953 950
 
954
-	public function getResultProperty(){ return $this->_property; }
955
-	public function setResultProperty($value){ $this->_property = $value; }
951
+	public function getResultProperty() { return $this->_property; }
952
+	public function setResultProperty($value) { $this->_property = $value; }
956 953
 
957
-	public function getResultObject(){ return $this->_resultObject; }
958
-	public function setResultObject($value){ $this->_resultObject = $value; }
954
+	public function getResultObject() { return $this->_resultObject; }
955
+	public function setResultObject($value) { $this->_resultObject = $value; }
959 956
 
960
-	public function getKeys(){ return $this->_keys; }
961
-	public function setKeys($value){ $this->_keys = $value; }
957
+	public function getKeys() { return $this->_keys; }
958
+	public function setKeys($value) { $this->_keys = $value; }
962 959
 
963
-	public function getMethod(){ return $this->_method; }
964
-	public function setMethod($value){ $this->_method = $value; }
960
+	public function getMethod() { return $this->_method; }
961
+	public function setMethod($value) { $this->_method = $value; }
965 962
 }
966 963
 
967 964
 /**
@@ -1004,26 +1001,26 @@  discard block
 block discarded – undo
1004 1001
 	 * @param string new node id
1005 1002
 	 * @param mixed node value
1006 1003
 	 */
1007
-	public function add($parent, $node, $object='')
1004
+	public function add($parent, $node, $object = '')
1008 1005
 	{
1009
-		if(isset($this->_entries[$parent]) && ($this->_entries[$parent]!==null)
1010
-			&& isset($this->_entries[$node]) && ($this->_entries[$node]!==null))
1006
+		if (isset($this->_entries[$parent]) && ($this->_entries[$parent] !== null)
1007
+			&& isset($this->_entries[$node]) && ($this->_entries[$node] !== null))
1011 1008
 		{
1012 1009
 			$this->_entries[$node] = $object;
1013 1010
 			return;
1014 1011
 		}
1015 1012
 		$this->_entries[$node] = $object;
1016
-		if(empty($parent))
1013
+		if (empty($parent))
1017 1014
 		{
1018
-			if(isset($this->_entries[$node]))
1015
+			if (isset($this->_entries[$node]))
1019 1016
 				return;
1020 1017
 			$this->_tree[$node] = array();
1021 1018
 		}
1022 1019
 		$found = $this->addNode($this->_tree, $parent, $node);
1023
-		if(!$found && !empty($parent))
1020
+		if (!$found && !empty($parent))
1024 1021
 		{
1025 1022
 			$this->_tree[$parent] = array();
1026
-			if(!isset($this->_entries[$parent]) || $object !== '')
1023
+			if (!isset($this->_entries[$parent]) || $object !== '')
1027 1024
 				$this->_entries[$parent] = $object;
1028 1025
 			$this->addNode($this->_tree, $parent, $node);
1029 1026
 		}
@@ -1040,11 +1037,11 @@  discard block
 block discarded – undo
1040 1037
 	{
1041 1038
 		$found = false;
1042 1039
 		reset($childs);
1043
-		for($i = 0, $k = count($childs); $i < $k; $i++)
1040
+		for ($i = 0, $k = count($childs); $i < $k; $i++)
1044 1041
 		{
1045 1042
 			$key = key($childs);
1046 1043
 			next($childs);
1047
-			if($key == $parent)
1044
+			if ($key == $parent)
1048 1045
 			{
1049 1046
 				$found = true;
1050 1047
 				$childs[$key][$node] = array();
@@ -1062,7 +1059,7 @@  discard block
 block discarded – undo
1062 1059
 	 */
1063 1060
 	public function collect()
1064 1061
 	{
1065
-		while(count($this->_tree) > 0)
1062
+		while (count($this->_tree) > 0)
1066 1063
 			$this->collectChildren(null, $this->_tree);
1067 1064
 		return $this->getCollection();
1068 1065
 	}
@@ -1074,8 +1071,8 @@  discard block
 block discarded – undo
1074 1071
 	protected function hasChildren(&$nodes)
1075 1072
 	{
1076 1073
 		$hasChildren = false;
1077
-		foreach($nodes as $node)
1078
-			if(count($node) != 0)
1074
+		foreach ($nodes as $node)
1075
+			if (count($node) != 0)
1079 1076
 				return true;
1080 1077
 		return $hasChildren;
1081 1078
 	}
@@ -1089,10 +1086,10 @@  discard block
 block discarded – undo
1089 1086
 	{
1090 1087
 		$noChildren = !$this->hasChildren($nodes);
1091 1088
 		$childs = array();
1092
-		for(reset($nodes); $key = key($nodes);)
1089
+		for (reset($nodes); $key = key($nodes);)
1093 1090
 		{
1094 1091
 			next($nodes);
1095
-			if($noChildren)
1092
+			if ($noChildren)
1096 1093
 			{
1097 1094
 				$childs[] = $key;
1098 1095
 				unset($nodes[$key]);
@@ -1100,7 +1097,7 @@  discard block
 block discarded – undo
1100 1097
 			else
1101 1098
 				$this->collectChildren($key, $nodes[$key]);
1102 1099
 		}
1103
-		if(count($childs) > 0)
1100
+		if (count($childs) > 0)
1104 1101
 			$this->onChildNodesVisited($parent, $childs);
1105 1102
 	}
1106 1103
 
@@ -1111,7 +1108,7 @@  discard block
 block discarded – undo
1111 1108
 	 */
1112 1109
 	protected function onChildNodesVisited($parent, $nodes)
1113 1110
 	{
1114
-		if(empty($parent) || empty($this->_entries[$parent]))
1111
+		if (empty($parent) || empty($this->_entries[$parent]))
1115 1112
 			return;
1116 1113
 
1117 1114
 		$parentObject = $this->_entries[$parent]['object'];
@@ -1119,21 +1116,21 @@  discard block
 block discarded – undo
1119 1116
 
1120 1117
 		$list = TPropertyAccess::get($parentObject, $property);
1121 1118
 
1122
-		foreach($nodes as $node)
1119
+		foreach ($nodes as $node)
1123 1120
 		{
1124
-			if($list instanceof TList)
1121
+			if ($list instanceof TList)
1125 1122
 				$parentObject->{$property}[] = $this->_entries[$node]['object'];
1126
-			else if(is_array($list))
1123
+			else if (is_array($list))
1127 1124
 				$list[] = $this->_entries[$node]['object'];
1128 1125
 			else
1129 1126
 				throw new TSqlMapExecutionException(
1130 1127
 					'sqlmap_property_must_be_list');
1131 1128
 		}
1132 1129
 
1133
-		if(is_array($list))
1130
+		if (is_array($list))
1134 1131
 			TPropertyAccess::set($parentObject, $property, $list);
1135 1132
 
1136
-		if($this->_entries[$parent]['property'] === null)
1133
+		if ($this->_entries[$parent]['property'] === null)
1137 1134
 			$this->_list[] = $parentObject;
1138 1135
 	}
1139 1136
 
@@ -1151,7 +1148,7 @@  discard block
 block discarded – undo
1151 1148
 		if (!count($this->_tree)) $exprops[] = "\0$cn\0_tree";
1152 1149
 		if (!count($this->_entries)) $exprops[] = "\0$cn\0_entries";
1153 1150
 		if (!count($this->_list)) $exprops[] = "\0$cn\0_list";
1154
-		return array_diff(parent::__sleep(),$exprops);
1151
+		return array_diff(parent::__sleep(), $exprops);
1155 1152
 	}
1156 1153
 }
1157 1154
 
Please login to merge, or discard this patch.
Braces   +173 added lines, -134 removed lines patch added patch discarded remove patch
@@ -237,8 +237,7 @@  discard block
 block discarded – undo
237 237
 				$param = new TResultSetListItemParameter($obj, $parameter, $list);
238 238
 				$this->raiseRowDelegate($delegate, $param);
239 239
 			}
240
-		}
241
-		else
240
+		} else
242 241
 		{
243 242
 			//var_dump($sql,$parameter);
244 243
 			foreach($reader as $row)
@@ -314,8 +313,7 @@  discard block
 block discarded – undo
314 313
 				$param = new TResultSetMapItemParameter($key, $value, $parameter, $map);
315 314
 				$this->raiseRowDelegate($delegate, $param);
316 315
 			}
317
-		}
318
-		else
316
+		} else
319 317
 		{
320 318
 			//while($row = $recordSet->fetchRow())
321 319
 			foreach($reader as $row)
@@ -341,14 +339,14 @@  discard block
 block discarded – undo
341 339
 		if(is_string($handler))
342 340
 		{
343 341
 			call_user_func($handler,$this,$param);
344
-		}
345
-		else if(is_callable($handler,true))
342
+		} else if(is_callable($handler,true))
346 343
 		{
347 344
 			// an array: 0 - object, 1 - method name/path
348 345
 			list($object,$method)=$handler;
349
-			if(is_string($object))	// static method call
346
+			if(is_string($object)) {
347
+				// static method call
350 348
 				call_user_func($handler,$this,$param);
351
-			else
349
+			} else
352 350
 			{
353 351
 				if(($pos=strrpos($method,'.'))!==false)
354 352
 				{
@@ -357,9 +355,9 @@  discard block
 block discarded – undo
357 355
 				}
358 356
 				$object->$method($this,$param);
359 357
 			}
358
+		} else {
359
+					throw new TInvalidDataValueException('sqlmap_invalid_delegate', $this->getID(), $handler);
360 360
 		}
361
-		else
362
-			throw new TInvalidDataValueException('sqlmap_invalid_delegate', $this->getID(), $handler);
363 361
 	}
364 362
 
365 363
 	/**
@@ -393,8 +391,9 @@  discard block
 block discarded – undo
393 391
 	{
394 392
 		$object = null;
395 393
 		$connection->setActive(true);
396
-		foreach($command->query() as $row)
397
-			$object = $this->applyResultMap($row, $result);
394
+		foreach($command->query() as $row) {
395
+					$object = $this->applyResultMap($row, $result);
396
+		}
398 397
 
399 398
 		if(!$this->_groupBy->isEmpty())
400 399
 		{
@@ -424,8 +423,9 @@  discard block
 block discarded – undo
424 423
 //		var_dump($command,$parameter);
425 424
 		$result = $command->execute();
426 425
 
427
-		if($generatedKey===null)
428
-			$generatedKey = $this->getPostGeneratedSelectKey($connection, $parameter);
426
+		if($generatedKey===null) {
427
+					$generatedKey = $this->getPostGeneratedSelectKey($connection, $parameter);
428
+		}
429 429
 
430 430
 		$this->executePostSelect($connection);
431 431
 		$this->onExecuteQuery($command);
@@ -443,8 +443,9 @@  discard block
 block discarded – undo
443 443
 		if($this->_statement instanceof TSqlMapInsert)
444 444
 		{
445 445
 			$selectKey = $this->_statement->getSelectKey();
446
-			if(($selectKey!==null) && !$selectKey->getIsAfter())
447
-				return $this->executeSelectKey($connection, $parameter, $selectKey);
446
+			if(($selectKey!==null) && !$selectKey->getIsAfter()) {
447
+							return $this->executeSelectKey($connection, $parameter, $selectKey);
448
+			}
448 449
 		}
449 450
 	}
450 451
 
@@ -459,8 +460,9 @@  discard block
 block discarded – undo
459 460
 		if($this->_statement instanceof TSqlMapInsert)
460 461
 		{
461 462
 			$selectKey = $this->_statement->getSelectKey();
462
-			if(($selectKey!==null) && $selectKey->getIsAfter())
463
-				return $this->executeSelectKey($connection, $parameter, $selectKey);
463
+			if(($selectKey!==null) && $selectKey->getIsAfter()) {
464
+							return $this->executeSelectKey($connection, $parameter, $selectKey);
465
+			}
464 466
 		}
465 467
 	}
466 468
 
@@ -476,8 +478,9 @@  discard block
 block discarded – undo
476 478
 		$mappedStatement = $this->getManager()->getMappedStatement($selectKey->getID());
477 479
 		$generatedKey = $mappedStatement->executeQueryForObject(
478 480
 									$connection, $parameter, null);
479
-		if(strlen($prop = $selectKey->getProperty()) > 0)
480
-				TPropertyAccess::set($parameter, $prop, $generatedKey);
481
+		if(strlen($prop = $selectKey->getProperty()) > 0) {
482
+						TPropertyAccess::set($parameter, $prop, $generatedKey);
483
+		}
481 484
 		return $generatedKey;
482 485
 	}
483 486
 
@@ -517,11 +520,11 @@  discard block
 block discarded – undo
517 520
 			{
518 521
 				$values = $statement->executeQueryForList($connection, $keys, null);
519 522
 
520
-				if($method == self::QUERY_FOR_ARRAY)
521
-					$values = $values->toArray();
523
+				if($method == self::QUERY_FOR_ARRAY) {
524
+									$values = $values->toArray();
525
+				}
522 526
 				TPropertyAccess::set($resultObject, $property, $values);
523
-			}
524
-			else if($method == self::QUERY_FOR_OBJECT)
527
+			} else if($method == self::QUERY_FOR_OBJECT)
525 528
 			{
526 529
 				$value = $statement->executeQueryForObject($connection, $keys, null);
527 530
 				TPropertyAccess::set($resultObject, $property, $value);
@@ -546,21 +549,25 @@  discard block
 block discarded – undo
546 549
 	 */
547 550
 	protected function applyResultMap($row, &$resultObject=null)
548 551
 	{
549
-		if($row === false) return null;
552
+		if($row === false) {
553
+			return null;
554
+		}
550 555
 
551 556
 		$resultMapName = $this->_statement->getResultMap();
552 557
 		$resultClass = $this->_statement->getResultClass();
553 558
 
554 559
 		$obj=null;
555
-		if($this->getManager()->getResultMaps()->contains($resultMapName))
556
-			$obj = $this->fillResultMap($resultMapName, $row, null, $resultObject);
557
-		else if(strlen($resultClass) > 0)
558
-			$obj = $this->fillResultClass($resultClass, $row, $resultObject);
559
-		else
560
-			$obj = $this->fillDefaultResultMap(null, $row, $resultObject);
561
-		if(class_exists('TActiveRecord',false) && $obj instanceof TActiveRecord)
562
-			//Create a new clean active record.
560
+		if($this->getManager()->getResultMaps()->contains($resultMapName)) {
561
+					$obj = $this->fillResultMap($resultMapName, $row, null, $resultObject);
562
+		} else if(strlen($resultClass) > 0) {
563
+					$obj = $this->fillResultClass($resultClass, $row, $resultObject);
564
+		} else {
565
+					$obj = $this->fillDefaultResultMap(null, $row, $resultObject);
566
+		}
567
+		if(class_exists('TActiveRecord',false) && $obj instanceof TActiveRecord) {
568
+					//Create a new clean active record.
563 569
 			$obj=TActiveRecord::createRecord(get_class($obj),$obj);
570
+		}
564 571
 		return $obj;
565 572
 	}
566 573
 
@@ -579,12 +586,13 @@  discard block
 block discarded – undo
579 586
 			$resultObject = $this->_statement->createInstanceOfResultClass($registry,$row);
580 587
 		}
581 588
 
582
-		if($resultObject instanceOf ArrayAccess)
583
-			return $this->fillResultArrayList($row, $resultObject);
584
-		else if(is_object($resultObject))
585
-			return $this->fillResultObjectProperty($row, $resultObject);
586
-		else
587
-			return $this->fillDefaultResultMap(null, $row, $resultObject);
589
+		if($resultObject instanceOf ArrayAccess) {
590
+					return $this->fillResultArrayList($row, $resultObject);
591
+		} else if(is_object($resultObject)) {
592
+					return $this->fillResultObjectProperty($row, $resultObject);
593
+		} else {
594
+					return $this->fillDefaultResultMap(null, $row, $resultObject);
595
+		}
588 596
 	}
589 597
 
590 598
 	/**
@@ -595,12 +603,13 @@  discard block
 block discarded – undo
595 603
 	 */
596 604
 	protected function fillResultArrayList($row, $resultObject)
597 605
 	{
598
-		if($resultObject instanceof TList)
599
-			foreach($row as $v)
606
+		if($resultObject instanceof TList) {
607
+					foreach($row as $v)
600 608
 				$resultObject[] = $v;
601
-		else
602
-			foreach($row as $k => $v)
609
+		} else {
610
+					foreach($row as $k => $v)
603 611
 				$resultObject[$k] = $v;
612
+		}
604 613
 		return $resultObject;
605 614
 	}
606 615
 
@@ -617,8 +626,9 @@  discard block
 block discarded – undo
617 626
 		foreach($row as $k=>$v)
618 627
 		{
619 628
 			$property = new TResultProperty;
620
-			if(is_string($k) && strlen($k) > 0)
621
-				$property->setColumn($k);
629
+			if(is_string($k) && strlen($k) > 0) {
630
+							$property->setColumn($k);
631
+			}
622 632
 			$property->setColumnIndex(++$index);
623 633
 			$type = gettype(TPropertyAccess::get($resultObject,$k));
624 634
 			$property->setType($type);
@@ -641,18 +651,19 @@  discard block
 block discarded – undo
641 651
 		$registry = $this->getManager()->getTypeHandlers();
642 652
 		$resultMap = $resultMap->resolveSubMap($registry,$row);
643 653
 
644
-		if($resultObject===null)
645
-			$resultObject = $resultMap->createInstanceOfResult($registry);
654
+		if($resultObject===null) {
655
+					$resultObject = $resultMap->createInstanceOfResult($registry);
656
+		}
646 657
 
647 658
 		if(is_object($resultObject))
648 659
 		{
649
-			if(strlen($resultMap->getGroupBy()) > 0)
650
-				return $this->addResultMapGroupBy($resultMap, $row, $parentGroup, $resultObject);
651
-			else
652
-				foreach($resultMap->getColumns() as $property)
660
+			if(strlen($resultMap->getGroupBy()) > 0) {
661
+							return $this->addResultMapGroupBy($resultMap, $row, $parentGroup, $resultObject);
662
+			} else {
663
+							foreach($resultMap->getColumns() as $property)
653 664
 					$this->setObjectProperty($resultMap, $property, $row, $resultObject);
654
-		}
655
-		else
665
+			}
666
+		} else
656 667
 		{
657 668
 			$resultObject = $this->fillDefaultResultMap($resultMap, $row, $resultObject);
658 669
 		}
@@ -690,18 +701,20 @@  discard block
 block discarded – undo
690 701
 				$groupKey = $this->getResultMapGroupKey($nestedMap, $row);
691 702
 
692 703
 				//add the node reference first
693
-				if(empty($parent))
694
-					$this->_groupBy->add($group, $groupKey, '');
704
+				if(empty($parent)) {
705
+									$this->_groupBy->add($group, $groupKey, '');
706
+				}
695 707
 
696 708
 				//get the nested result mapping value
697 709
 				$value = $this->fillResultMap($nested, $row, $groupKey);
698 710
 
699 711
 				//add it to the object tree graph
700 712
 				$groupObject = array('object'=>$value, 'property' => $property->getProperty());
701
-				if(empty($parent))
702
-					$this->_groupBy->add($group, $groupKey, $groupObject);
703
-				else
704
-					$this->_groupBy->add($parent, $groupKey, $groupObject);
713
+				if(empty($parent)) {
714
+									$this->_groupBy->add($group, $groupKey, $groupObject);
715
+				} else {
716
+									$this->_groupBy->add($parent, $groupKey, $groupObject);
717
+				}
705 718
 			}
706 719
 		}
707 720
 		return $resultObject;
@@ -716,10 +729,11 @@  discard block
 block discarded – undo
716 729
 	protected function getResultMapGroupKey($resultMap, $row)
717 730
 	{
718 731
 		$groupBy = $resultMap->getGroupBy();
719
-		if(isset($row[$groupBy]))
720
-			return $resultMap->getID().$row[$groupBy];
721
-		else
722
-			return $resultMap->getID().crc32(serialize($row));
732
+		if(isset($row[$groupBy])) {
733
+					return $resultMap->getID().$row[$groupBy];
734
+		} else {
735
+					return $resultMap->getID().crc32(serialize($row));
736
+		}
723 737
 	}
724 738
 
725 739
 	/**
@@ -732,19 +746,22 @@  discard block
 block discarded – undo
732 746
 	 */
733 747
 	protected function fillDefaultResultMap($resultMap, $row, $resultObject)
734 748
 	{
735
-		if($resultObject===null)
736
-			$resultObject='';
749
+		if($resultObject===null) {
750
+					$resultObject='';
751
+		}
737 752
 
738
-		if($resultMap!==null)
739
-			$result = $this->fillArrayResultMap($resultMap, $row, $resultObject);
740
-		else
741
-			$result = $row;
753
+		if($resultMap!==null) {
754
+					$result = $this->fillArrayResultMap($resultMap, $row, $resultObject);
755
+		} else {
756
+					$result = $row;
757
+		}
742 758
 
743 759
 		//if scalar result types
744
-		if(count($result) == 1 && ($type = gettype($resultObject))!= 'array')
745
-			return $this->getScalarResult($result, $type);
746
-		else
747
-			return $result;
760
+		if(count($result) == 1 && ($type = gettype($resultObject))!= 'array') {
761
+					return $this->getScalarResult($result, $type);
762
+		} else {
763
+					return $result;
764
+		}
748 765
 	}
749 766
 
750 767
 	/**
@@ -761,8 +778,9 @@  discard block
 block discarded – undo
761 778
 		foreach($resultMap->getColumns() as $column)
762 779
 		{
763 780
 			if(($column->getType()===null)
764
-				&& ($resultObject!==null) && !is_object($resultObject))
765
-			$column->setType(gettype($resultObject));
781
+				&& ($resultObject!==null) && !is_object($resultObject)) {
782
+						$column->setType(gettype($resultObject));
783
+			}
766 784
 			$result[$column->getProperty()] = $column->getPropertyValue($registry,$row);
767 785
 		}
768 786
 		return $result;
@@ -797,35 +815,34 @@  discard block
 block discarded – undo
797 815
 		if($key === '')
798 816
 		{
799 817
 			$resultObject = $property->getPropertyValue($registry,$row);
800
-		}
801
-		else if(strlen($select) == 0 && ($nested===null))
818
+		} else if(strlen($select) == 0 && ($nested===null))
802 819
 		{
803 820
 			$value = $property->getPropertyValue($registry,$row);
804 821
 
805 822
 			$this->_IsRowDataFound = $this->_IsRowDataFound || ($value != null);
806
-			if(is_array($resultObject) || is_object($resultObject))
807
-				TPropertyAccess::set($resultObject, $key, $value);
808
-			else
809
-				$resultObject = $value;
810
-		}
811
-		else if($nested!==null)
823
+			if(is_array($resultObject) || is_object($resultObject)) {
824
+							TPropertyAccess::set($resultObject, $key, $value);
825
+			} else {
826
+							$resultObject = $value;
827
+			}
828
+		} else if($nested!==null)
812 829
 		{
813 830
 			if($property->instanceOfListType($resultObject) || $property->instanceOfArrayType($resultObject))
814 831
 			{
815
-				if(strlen($resultMap->getGroupBy()) <= 0)
816
-					throw new TSqlMapExecutionException(
832
+				if(strlen($resultMap->getGroupBy()) <= 0) {
833
+									throw new TSqlMapExecutionException(
817 834
 						'sqlmap_non_groupby_array_list_type', $resultMap->getID(),
818 835
 						get_class($resultObject), $key);
819
-			}
820
-			else
836
+				}
837
+			} else
821 838
 			{
822 839
 				$obj = $nested->createInstanceOfResult($this->getManager()->getTypeHandlers());
823
-				if($this->fillPropertyWithResultMap($nested, $row, $obj) == false)
824
-					$obj = null;
840
+				if($this->fillPropertyWithResultMap($nested, $row, $obj) == false) {
841
+									$obj = null;
842
+				}
825 843
 				TPropertyAccess::set($resultObject, $key, $obj);
826 844
 			}
827
-		}
828
-		else //'select' ResultProperty
845
+		} else //'select' ResultProperty
829 846
 		{
830 847
 			$this->enquequePostSelect($select, $resultMap, $property, $row, $resultObject);
831 848
 		}
@@ -857,17 +874,18 @@  discard block
 block discarded – undo
857 874
 				$values = TLazyLoadList::newInstance($statement, $key,
858 875
 								$resultObject, $property->getProperty());
859 876
 				TPropertyAccess::set($resultObject, $property->getProperty(), $values);
877
+			} else {
878
+							$postSelect->setMethod(self::QUERY_FOR_LIST);
860 879
 			}
861
-			else
862
-				$postSelect->setMethod(self::QUERY_FOR_LIST);
880
+		} else if($property->instanceOfArrayType($resultObject)) {
881
+					$postSelect->setMethod(self::QUERY_FOR_ARRAY);
882
+		} else {
883
+					$postSelect->setMethod(self::QUERY_FOR_OBJECT);
863 884
 		}
864
-		else if($property->instanceOfArrayType($resultObject))
865
-			$postSelect->setMethod(self::QUERY_FOR_ARRAY);
866
-		else
867
-			$postSelect->setMethod(self::QUERY_FOR_OBJECT);
868 885
 
869
-		if(!$property->getLazyLoad())
870
-			$this->_selectQueue[] = $postSelect;
886
+		if(!$property->getLazyLoad()) {
887
+					$this->_selectQueue[] = $postSelect;
888
+		}
871 889
 	}
872 890
 
873 891
 	/**
@@ -889,8 +907,7 @@  discard block
 block discarded – undo
889 907
 				$keys[trim($pair[0])] = $row[trim($pair[1])];
890 908
 			}
891 909
 			return $keys;
892
-		}
893
-		else
910
+		} else
894 911
 		{
895 912
 			$registry=$this->getManager()->getTypeHandlers();
896 913
 			return $property->getPropertyValue($registry,$row);
@@ -920,15 +937,23 @@  discard block
 block discarded – undo
920 937
 	public function __wakeup()
921 938
 	{
922 939
 		parent::__wakeup();
923
-		if (is_null($this->_selectQueue)) $this->_selectQueue = array();
940
+		if (is_null($this->_selectQueue)) {
941
+			$this->_selectQueue = array();
942
+		}
924 943
 	}
925 944
 
926 945
 	public function __sleep()
927 946
 	{
928 947
 		$exprops = array(); $cn = __CLASS__;
929
-		if (!count($this->_selectQueue)) $exprops[] = "\0$cn\0_selectQueue";
930
-		if (is_null($this->_groupBy)) $exprops[] = "\0$cn\0_groupBy";
931
-		if (!$this->_IsRowDataFound) $exprops[] = "\0$cn\0_IsRowDataFound";
948
+		if (!count($this->_selectQueue)) {
949
+			$exprops[] = "\0$cn\0_selectQueue";
950
+		}
951
+		if (is_null($this->_groupBy)) {
952
+			$exprops[] = "\0$cn\0_groupBy";
953
+		}
954
+		if (!$this->_IsRowDataFound) {
955
+			$exprops[] = "\0$cn\0_IsRowDataFound";
956
+		}
932 957
 		return array_diff(parent::__sleep(),$exprops);
933 958
 	}
934 959
 }
@@ -1015,16 +1040,18 @@  discard block
 block discarded – undo
1015 1040
 		$this->_entries[$node] = $object;
1016 1041
 		if(empty($parent))
1017 1042
 		{
1018
-			if(isset($this->_entries[$node]))
1019
-				return;
1043
+			if(isset($this->_entries[$node])) {
1044
+							return;
1045
+			}
1020 1046
 			$this->_tree[$node] = array();
1021 1047
 		}
1022 1048
 		$found = $this->addNode($this->_tree, $parent, $node);
1023 1049
 		if(!$found && !empty($parent))
1024 1050
 		{
1025 1051
 			$this->_tree[$parent] = array();
1026
-			if(!isset($this->_entries[$parent]) || $object !== '')
1027
-				$this->_entries[$parent] = $object;
1052
+			if(!isset($this->_entries[$parent]) || $object !== '') {
1053
+							$this->_entries[$parent] = $object;
1054
+			}
1028 1055
 			$this->addNode($this->_tree, $parent, $node);
1029 1056
 		}
1030 1057
 	}
@@ -1048,8 +1075,7 @@  discard block
 block discarded – undo
1048 1075
 			{
1049 1076
 				$found = true;
1050 1077
 				$childs[$key][$node] = array();
1051
-			}
1052
-			else
1078
+			} else
1053 1079
 			{
1054 1080
 				$found = $found || $this->addNode($childs[$key], $parent, $node);
1055 1081
 			}
@@ -1062,8 +1088,9 @@  discard block
 block discarded – undo
1062 1088
 	 */
1063 1089
 	public function collect()
1064 1090
 	{
1065
-		while(count($this->_tree) > 0)
1066
-			$this->collectChildren(null, $this->_tree);
1091
+		while(count($this->_tree) > 0) {
1092
+					$this->collectChildren(null, $this->_tree);
1093
+		}
1067 1094
 		return $this->getCollection();
1068 1095
 	}
1069 1096
 
@@ -1074,9 +1101,10 @@  discard block
 block discarded – undo
1074 1101
 	protected function hasChildren(&$nodes)
1075 1102
 	{
1076 1103
 		$hasChildren = false;
1077
-		foreach($nodes as $node)
1078
-			if(count($node) != 0)
1104
+		foreach($nodes as $node) {
1105
+					if(count($node) != 0)
1079 1106
 				return true;
1107
+		}
1080 1108
 		return $hasChildren;
1081 1109
 	}
1082 1110
 
@@ -1096,12 +1124,13 @@  discard block
 block discarded – undo
1096 1124
 			{
1097 1125
 				$childs[] = $key;
1098 1126
 				unset($nodes[$key]);
1127
+			} else {
1128
+							$this->collectChildren($key, $nodes[$key]);
1099 1129
 			}
1100
-			else
1101
-				$this->collectChildren($key, $nodes[$key]);
1102 1130
 		}
1103
-		if(count($childs) > 0)
1104
-			$this->onChildNodesVisited($parent, $childs);
1131
+		if(count($childs) > 0) {
1132
+					$this->onChildNodesVisited($parent, $childs);
1133
+		}
1105 1134
 	}
1106 1135
 
1107 1136
 	/**
@@ -1111,8 +1140,9 @@  discard block
 block discarded – undo
1111 1140
 	 */
1112 1141
 	protected function onChildNodesVisited($parent, $nodes)
1113 1142
 	{
1114
-		if(empty($parent) || empty($this->_entries[$parent]))
1115
-			return;
1143
+		if(empty($parent) || empty($this->_entries[$parent])) {
1144
+					return;
1145
+		}
1116 1146
 
1117 1147
 		$parentObject = $this->_entries[$parent]['object'];
1118 1148
 		$property = $this->_entries[$nodes[0]]['property'];
@@ -1121,20 +1151,23 @@  discard block
 block discarded – undo
1121 1151
 
1122 1152
 		foreach($nodes as $node)
1123 1153
 		{
1124
-			if($list instanceof TList)
1125
-				$parentObject->{$property}[] = $this->_entries[$node]['object'];
1126
-			else if(is_array($list))
1127
-				$list[] = $this->_entries[$node]['object'];
1128
-			else
1129
-				throw new TSqlMapExecutionException(
1154
+			if($list instanceof TList) {
1155
+							$parentObject->{$property}[] = $this->_entries[$node]['object'];
1156
+			} else if(is_array($list)) {
1157
+							$list[] = $this->_entries[$node]['object'];
1158
+			} else {
1159
+							throw new TSqlMapExecutionException(
1130 1160
 					'sqlmap_property_must_be_list');
1161
+			}
1131 1162
 		}
1132 1163
 
1133
-		if(is_array($list))
1134
-			TPropertyAccess::set($parentObject, $property, $list);
1164
+		if(is_array($list)) {
1165
+					TPropertyAccess::set($parentObject, $property, $list);
1166
+		}
1135 1167
 
1136
-		if($this->_entries[$parent]['property'] === null)
1137
-			$this->_list[] = $parentObject;
1168
+		if($this->_entries[$parent]['property'] === null) {
1169
+					$this->_list[] = $parentObject;
1170
+		}
1138 1171
 	}
1139 1172
 
1140 1173
 	/**
@@ -1148,9 +1181,15 @@  discard block
 block discarded – undo
1148 1181
 	public function __sleep()
1149 1182
 	{
1150 1183
 		$exprops = array(); $cn = __CLASS__;
1151
-		if (!count($this->_tree)) $exprops[] = "\0$cn\0_tree";
1152
-		if (!count($this->_entries)) $exprops[] = "\0$cn\0_entries";
1153
-		if (!count($this->_list)) $exprops[] = "\0$cn\0_list";
1184
+		if (!count($this->_tree)) {
1185
+			$exprops[] = "\0$cn\0_tree";
1186
+		}
1187
+		if (!count($this->_entries)) {
1188
+			$exprops[] = "\0$cn\0_entries";
1189
+		}
1190
+		if (!count($this->_list)) {
1191
+			$exprops[] = "\0$cn\0_list";
1192
+		}
1154 1193
 		return array_diff(parent::__sleep(),$exprops);
1155 1194
 	}
1156 1195
 }
Please login to merge, or discard this patch.
framework/Data/SqlMap/Statements/TPreparedCommand.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -21,6 +21,9 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class TPreparedCommand
23 23
 {
24
+	/**
25
+	 * @param TSqlMapStatement $statement
26
+	 */
24 27
 	public function create(TSqlMapManager $manager, $connection, $statement, $parameterObject,$skip=null,$max=null)
25 28
 	{
26 29
 		$sqlText = $statement->getSQLText();
@@ -43,6 +46,9 @@  discard block
 block discarded – undo
43 46
 		return $command;
44 47
 	}
45 48
 
49
+	/**
50
+	 * @param TSqlMapManager $manager
51
+	 */
46 52
 	protected function applyParameterMap($manager,$command,$prepared, $statement, $parameterObject)
47 53
 	{
48 54
 		$properties = $prepared->getParameterNames(false);
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class TPreparedCommand
23 23
 {
24
-	public function create(TSqlMapManager $manager, $connection, $statement, $parameterObject,$skip=null,$max=null)
24
+	public function create(TSqlMapManager $manager, $connection, $statement, $parameterObject, $skip = null, $max = null)
25 25
 	{
26 26
 		$sqlText = $statement->getSQLText();
27 27
 
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
 		$connection->setActive(true);
30 30
 		$sql = $prepared->getPreparedSql();
31 31
 
32
-		if($sqlText instanceof TSimpleDynamicSql)
32
+		if ($sqlText instanceof TSimpleDynamicSql)
33 33
 			$sql = $sqlText->replaceDynamicParameter($sql, $parameterObject);
34 34
 
35
-		if($max!==null || $skip!==null)
35
+		if ($max !== null || $skip !== null)
36 36
 		{
37 37
 			$builder = TDbMetaData::getInstance($connection)->createCommandBuilder();
38
-			$sql = $builder->applyLimitOffset($sql,$max,$skip);
38
+			$sql = $builder->applyLimitOffset($sql, $max, $skip);
39 39
 		}
40 40
 		$command = $connection->createCommand($sql);
41 41
 		$this->applyParameterMap($manager, $command, $prepared, $statement, $parameterObject);
@@ -43,23 +43,23 @@  discard block
 block discarded – undo
43 43
 		return $command;
44 44
 	}
45 45
 
46
-	protected function applyParameterMap($manager,$command,$prepared, $statement, $parameterObject)
46
+	protected function applyParameterMap($manager, $command, $prepared, $statement, $parameterObject)
47 47
 	{
48 48
 		$properties = $prepared->getParameterNames(false);
49 49
 		//$parameters = $prepared->getParameterValues();
50
-		$registry=$manager->getTypeHandlers();
50
+		$registry = $manager->getTypeHandlers();
51 51
 		if ($properties)
52
-		for($i = 0, $k=$properties->getCount(); $i<$k; $i++)
52
+		for ($i = 0, $k = $properties->getCount(); $i < $k; $i++)
53 53
 		{
54 54
 			$property = $statement->parameterMap()->getProperty($i);
55
-			$value = $statement->parameterMap()->getPropertyValue($registry,$property, $parameterObject);
55
+			$value = $statement->parameterMap()->getPropertyValue($registry, $property, $parameterObject);
56 56
 			$dbType = $property->getDbType();
57
-			if($dbType=='') //relies on PHP lax comparison
58
-				$command->bindValue($i+1,$value, TDbCommandBuilder::getPdoType($value));
59
-			else if(strpos($dbType, 'PDO::')===0)
60
-				$command->bindValue($i+1,$value, constant($property->getDbType())); //assumes PDO types, e.g. PDO::PARAM_INT
57
+			if ($dbType == '') //relies on PHP lax comparison
58
+				$command->bindValue($i + 1, $value, TDbCommandBuilder::getPdoType($value));
59
+			else if (strpos($dbType, 'PDO::') === 0)
60
+				$command->bindValue($i + 1, $value, constant($property->getDbType())); //assumes PDO types, e.g. PDO::PARAM_INT
61 61
 			else
62
-				$command->bindValue($i+1,$value);
62
+				$command->bindValue($i + 1, $value);
63 63
 		}
64 64
 	}
65 65
 }
Please login to merge, or discard this patch.
Braces   +16 added lines, -9 removed lines patch added patch discarded remove patch
@@ -29,8 +29,9 @@  discard block
 block discarded – undo
29 29
 		$connection->setActive(true);
30 30
 		$sql = $prepared->getPreparedSql();
31 31
 
32
-		if($sqlText instanceof TSimpleDynamicSql)
33
-			$sql = $sqlText->replaceDynamicParameter($sql, $parameterObject);
32
+		if($sqlText instanceof TSimpleDynamicSql) {
33
+					$sql = $sqlText->replaceDynamicParameter($sql, $parameterObject);
34
+		}
34 35
 
35 36
 		if($max!==null || $skip!==null)
36 37
 		{
@@ -48,18 +49,24 @@  discard block
 block discarded – undo
48 49
 		$properties = $prepared->getParameterNames(false);
49 50
 		//$parameters = $prepared->getParameterValues();
50 51
 		$registry=$manager->getTypeHandlers();
51
-		if ($properties)
52
-		for($i = 0, $k=$properties->getCount(); $i<$k; $i++)
52
+		if ($properties) {
53
+				for($i = 0, $k=$properties->getCount();
54
+		}
55
+		$i<$k; $i++)
53 56
 		{
54 57
 			$property = $statement->parameterMap()->getProperty($i);
55 58
 			$value = $statement->parameterMap()->getPropertyValue($registry,$property, $parameterObject);
56 59
 			$dbType = $property->getDbType();
57
-			if($dbType=='') //relies on PHP lax comparison
60
+			if($dbType=='') {
61
+				//relies on PHP lax comparison
58 62
 				$command->bindValue($i+1,$value, TDbCommandBuilder::getPdoType($value));
59
-			else if(strpos($dbType, 'PDO::')===0)
60
-				$command->bindValue($i+1,$value, constant($property->getDbType())); //assumes PDO types, e.g. PDO::PARAM_INT
61
-			else
62
-				$command->bindValue($i+1,$value);
63
+			} else if(strpos($dbType, 'PDO::')===0) {
64
+							$command->bindValue($i+1,$value, constant($property->getDbType()));
65
+			}
66
+			//assumes PDO types, e.g. PDO::PARAM_INT
67
+			else {
68
+							$command->bindValue($i+1,$value);
69
+			}
63 70
 		}
64 71
 	}
65 72
 }
Please login to merge, or discard this patch.
framework/Data/SqlMap/TSqlMapConfig.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -77,6 +77,7 @@
 block discarded – undo
77 77
 
78 78
 	/**
79 79
 	 * Saves the current SqlMap manager to cache.
80
+	 * @param TSqlMapManager $manager
80 81
 	 * @return boolean true if SqlMap manager was cached, false otherwise.
81 82
 	 */
82 83
 	protected function cacheSqlMapManager($manager)
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -24,19 +24,19 @@  discard block
 block discarded – undo
24 24
 {
25 25
 	private $_configFile;
26 26
 	private $_sqlmap;
27
-	private $_enableCache=false;
27
+	private $_enableCache = false;
28 28
 
29 29
 	/**
30 30
 	 * File extension of external configuration file
31 31
 	 */
32
-	const CONFIG_FILE_EXT='.xml';
32
+	const CONFIG_FILE_EXT = '.xml';
33 33
 
34 34
 	/**
35 35
 	 * @return string module ID + configuration file path.
36 36
 	 */
37 37
 	private function getCacheKey()
38 38
 	{
39
-		return $this->getID().$this->getConfigFile();
39
+		return $this->getID() . $this->getConfigFile();
40 40
 	}
41 41
 
42 42
 	/**
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	public function clearCache()
46 46
 	{
47 47
 		$cache = $this->getApplication()->getCache();
48
-		if($cache !== null) {
48
+		if ($cache !== null) {
49 49
 			$cache->delete($this->getCacheKey());
50 50
 		}
51 51
 	}
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
 	 */
61 61
 	public function getSqlMapManager() {
62 62
 		Prado::using('System.Data.SqlMap.TSqlMapManager');
63
-		if(($manager = $this->loadCachedSqlMapManager())===null)
63
+		if (($manager = $this->loadCachedSqlMapManager()) === null)
64 64
 		{
65 65
 			$manager = new TSqlMapManager($this->getDbConnection());
66
-			if(strlen($file=$this->getConfigFile()) > 0)
66
+			if (strlen($file = $this->getConfigFile()) > 0)
67 67
 			{
68 68
 				$manager->configureXml($file);
69 69
 				$this->cacheSqlMapManager($manager);
70 70
 			}
71 71
 		}
72
-		elseif($this->getConnectionID() !== '') {
72
+		elseif ($this->getConnectionID() !== '') {
73 73
 			$manager->setDbConnection($this->getDbConnection());
74 74
 		}
75 75
 		return $manager;
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	protected function cacheSqlMapManager($manager)
83 83
 	{
84
-		if($this->getEnableCache())
84
+		if ($this->getEnableCache())
85 85
 		{
86 86
 			$cache = $this->getApplication()->getCache();
87
-			if($cache !== null) {
87
+			if ($cache !== null) {
88 88
 				$dependencies = null;
89
-				if($this->getApplication()->getMode() !== TApplicationMode::Performance)
89
+				if ($this->getApplication()->getMode() !== TApplicationMode::Performance)
90 90
 					$dependencies = $manager->getCacheDependencies();
91 91
 				return $cache->set($this->getCacheKey(), $manager, 0, $dependencies);
92 92
 			}
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	protected function loadCachedSqlMapManager()
102 102
 	{
103
-		if($this->getEnableCache())
103
+		if ($this->getEnableCache())
104 104
 		{
105 105
 			$cache = $this->getApplication()->getCache();
106
-			if($cache !== null)
106
+			if ($cache !== null)
107 107
 			{
108 108
 				$manager = $cache->get($this->getCacheKey());
109
-				if($manager instanceof TSqlMapManager)
109
+				if ($manager instanceof TSqlMapManager)
110 110
 					return $manager;
111 111
 			}
112 112
 		}
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	public function setConfigFile($value)
130 130
 	{
131
-		if(is_file($value))
132
-			$this->_configFile=$value;
131
+		if (is_file($value))
132
+			$this->_configFile = $value;
133 133
 		else
134 134
 		{
135
-			$file = Prado::getPathOfNamespace($value,self::CONFIG_FILE_EXT);
136
-			if($file === null || !is_file($file))
137
-				throw new TConfigurationException('sqlmap_configfile_invalid',$value);
135
+			$file = Prado::getPathOfNamespace($value, self::CONFIG_FILE_EXT);
136
+			if ($file === null || !is_file($file))
137
+				throw new TConfigurationException('sqlmap_configfile_invalid', $value);
138 138
 			else
139 139
 				$this->_configFile = $file;
140 140
 		}
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	 */
172 172
 	public function getClient()
173 173
 	{
174
-		if($this->_sqlmap===null )
175
-			$this->_sqlmap=$this->createSqlMapGateway();
174
+		if ($this->_sqlmap === null)
175
+			$this->_sqlmap = $this->createSqlMapGateway();
176 176
 		return $this->_sqlmap;
177 177
 	}
178 178
 }
Please login to merge, or discard this patch.
Braces   +18 added lines, -15 removed lines patch added patch discarded remove patch
@@ -68,8 +68,7 @@  discard block
 block discarded – undo
68 68
 				$manager->configureXml($file);
69 69
 				$this->cacheSqlMapManager($manager);
70 70
 			}
71
-		}
72
-		elseif($this->getConnectionID() !== '') {
71
+		} elseif($this->getConnectionID() !== '') {
73 72
 			$manager->setDbConnection($this->getDbConnection());
74 73
 		}
75 74
 		return $manager;
@@ -86,8 +85,9 @@  discard block
 block discarded – undo
86 85
 			$cache = $this->getApplication()->getCache();
87 86
 			if($cache !== null) {
88 87
 				$dependencies = null;
89
-				if($this->getApplication()->getMode() !== TApplicationMode::Performance)
90
-					$dependencies = $manager->getCacheDependencies();
88
+				if($this->getApplication()->getMode() !== TApplicationMode::Performance) {
89
+									$dependencies = $manager->getCacheDependencies();
90
+				}
91 91
 				return $cache->set($this->getCacheKey(), $manager, 0, $dependencies);
92 92
 			}
93 93
 		}
@@ -106,8 +106,9 @@  discard block
 block discarded – undo
106 106
 			if($cache !== null)
107 107
 			{
108 108
 				$manager = $cache->get($this->getCacheKey());
109
-				if($manager instanceof TSqlMapManager)
110
-					return $manager;
109
+				if($manager instanceof TSqlMapManager) {
110
+									return $manager;
111
+				}
111 112
 			}
112 113
 		}
113 114
 		return null;
@@ -128,15 +129,16 @@  discard block
 block discarded – undo
128 129
 	 */
129 130
 	public function setConfigFile($value)
130 131
 	{
131
-		if(is_file($value))
132
-			$this->_configFile=$value;
133
-		else
132
+		if(is_file($value)) {
133
+					$this->_configFile=$value;
134
+		} else
134 135
 		{
135 136
 			$file = Prado::getPathOfNamespace($value,self::CONFIG_FILE_EXT);
136
-			if($file === null || !is_file($file))
137
-				throw new TConfigurationException('sqlmap_configfile_invalid',$value);
138
-			else
139
-				$this->_configFile = $file;
137
+			if($file === null || !is_file($file)) {
138
+							throw new TConfigurationException('sqlmap_configfile_invalid',$value);
139
+			} else {
140
+							$this->_configFile = $file;
141
+			}
140 142
 		}
141 143
 	}
142 144
 
@@ -171,8 +173,9 @@  discard block
 block discarded – undo
171 173
 	 */
172 174
 	public function getClient()
173 175
 	{
174
-		if($this->_sqlmap===null )
175
-			$this->_sqlmap=$this->createSqlMapGateway();
176
+		if($this->_sqlmap===null ) {
177
+					$this->_sqlmap=$this->createSqlMapGateway();
178
+		}
176 179
 		return $this->_sqlmap;
177 180
 	}
178 181
 }
Please login to merge, or discard this patch.
framework/Data/SqlMap/TSqlMapGateway.php 3 patches
Doc Comments   +16 added lines patch added patch discarded remove patch
@@ -32,6 +32,9 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	private $_manager;
34 34
 
35
+	/**
36
+	 * @param TSqlMapManager|null $manager
37
+	 */
35 38
 	public function __construct($manager)
36 39
 	{
37 40
 		$this->_manager=$manager;
@@ -63,6 +66,8 @@  discard block
 block discarded – undo
63 66
 	 * @param string The name of the sql statement to execute.
64 67
 	 * @param mixed The object used to set the parameters in the SQL.
65 68
 	 * @param mixed An object of the type to be returned.
69
+	 * @param string $statementName
70
+	 * @param Account $result
66 71
 	 * @return object A single result object populated with the result set data.
67 72
 	 */
68 73
 	public function queryForObject($statementName, $parameter=null, $result=null)
@@ -84,6 +89,8 @@  discard block
 block discarded – undo
84 89
 	 * pass in null if want to return a list instead.
85 90
 	 * @param int The number of rows to skip over.
86 91
 	 * @param int The maximum number of rows to return.
92
+	 * @param string $statementName
93
+	 * @param AccountCollection $result
87 94
 	 * @return TList A List of result objects.
88 95
 	 */
89 96
 	public function queryForList($statementName, $parameter=null, $result=null, $skip=-1, $max=-1)
@@ -105,6 +112,7 @@  discard block
 block discarded – undo
105 112
 	 * pass in null if want to return a list instead.
106 113
 	 * @param int The number of rows to skip over.
107 114
 	 * @param int The maximum number of rows to return.
115
+	 * @param string $statementName
108 116
 	 * @return TList A List of result objects.
109 117
 	 */
110 118
 	public function queryWithRowDelegate($statementName, $delegate, $parameter=null, $result=null, $skip=-1, $max=-1)
@@ -121,6 +129,7 @@  discard block
 block discarded – undo
121 129
 	 * @param mixed The object used to set the parameters in the SQL.
122 130
 	 * @param integer The maximum number of objects to store in each page.
123 131
 	 * @param integer The number of the page to initially load into the list.
132
+	 * @param string $statementName
124 133
 	 * @return TPagedList A PaginatedList of beans containing the rows.
125 134
 	 */
126 135
 	public function queryForPagedList($statementName, $parameter=null, $pageSize=10, $page=0)
@@ -161,6 +170,9 @@  discard block
 block discarded – undo
161 170
 	 * @param mixed The object used to set the parameters in the SQL.
162 171
 	 * @param string The property of the result object to be used as the key.
163 172
 	 * @param string The property of the result object to be used as the value.
173
+	 * @param string $statementName
174
+	 * @param string $keyProperty
175
+	 * @param string $valueProperty
164 176
 	 * @return TMap Array object containing the rows keyed by keyProperty.
165 177
 	 */
166 178
 	public function queryForMap($statementName, $parameter=null, $keyProperty=null, $valueProperty=null, $skip=-1, $max=-1)
@@ -180,6 +192,8 @@  discard block
 block discarded – undo
180 192
 	 * @param mixed The object used to set the parameters in the SQL.
181 193
 	 * @param string The property of the result object to be used as the key.
182 194
 	 * @param string The property of the result object to be used as the value.
195
+	 * @param string $statementName
196
+	 * @param string $keyProperty
183 197
 	 * @return TMap Array object containing the rows keyed by keyProperty.
184 198
 	 */
185 199
 	public function queryForMapWithRowDelegate($statementName, $delegate, $parameter=null, $keyProperty=null, $valueProperty=null, $skip=-1, $max=-1)
@@ -200,6 +214,7 @@  discard block
 block discarded – undo
200 214
 	 *
201 215
 	 * @param string The name of the statement to execute.
202 216
 	 * @param string The parameter object.
217
+	 * @param string $statementName
203 218
 	 * @return mixed The primary key of the newly inserted row.
204 219
 	 * This might be automatically generated by the RDBMS,
205 220
 	 * or selected from a sequence table or other source.
@@ -233,6 +248,7 @@  discard block
 block discarded – undo
233 248
 	 * Executes a Sql DELETE statement.  Delete returns the number of rows effected.
234 249
 	 * @param string The name of the statement to execute.
235 250
 	 * @param mixed The parameter object.
251
+	 * @param string $statementName
236 252
 	 * @return integer The number of rows effected.
237 253
 	 */
238 254
 	public function delete($statementName, $parameter=null)
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
 	public function __construct($manager)
36 36
 	{
37
-		$this->_manager=$manager;
37
+		$this->_manager = $manager;
38 38
 	}
39 39
 
40 40
 	/**
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 * @param mixed An object of the type to be returned.
66 66
 	 * @return object A single result object populated with the result set data.
67 67
 	 */
68
-	public function queryForObject($statementName, $parameter=null, $result=null)
68
+	public function queryForObject($statementName, $parameter = null, $result = null)
69 69
 	{
70 70
 		$statement = $this->getSqlMapManager()->getMappedStatement($statementName);
71 71
 		return $statement->executeQueryForObject($this->getDbConnection(), $parameter, $result);
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 	 * @param int The maximum number of rows to return.
87 87
 	 * @return TList A List of result objects.
88 88
 	 */
89
-	public function queryForList($statementName, $parameter=null, $result=null, $skip=-1, $max=-1)
89
+	public function queryForList($statementName, $parameter = null, $result = null, $skip = -1, $max = -1)
90 90
 	{
91 91
 		$statement = $this->getSqlMapManager()->getMappedStatement($statementName);
92
-		return $statement->executeQueryForList($this->getDbConnection(),$parameter, $result, $skip, $max);
92
+		return $statement->executeQueryForList($this->getDbConnection(), $parameter, $result, $skip, $max);
93 93
 	}
94 94
 
95 95
 	/**
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * @param int The maximum number of rows to return.
108 108
 	 * @return TList A List of result objects.
109 109
 	 */
110
-	public function queryWithRowDelegate($statementName, $delegate, $parameter=null, $result=null, $skip=-1, $max=-1)
110
+	public function queryWithRowDelegate($statementName, $delegate, $parameter = null, $result = null, $skip = -1, $max = -1)
111 111
 	{
112 112
 		$statement = $this->getSqlMapManager()->getMappedStatement($statementName);
113 113
 		return $statement->executeQueryForList($this->getDbConnection(), $parameter, $result, $skip, $max, $delegate);
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 * @param integer The number of the page to initially load into the list.
124 124
 	 * @return TPagedList A PaginatedList of beans containing the rows.
125 125
 	 */
126
-	public function queryForPagedList($statementName, $parameter=null, $pageSize=10, $page=0)
126
+	public function queryForPagedList($statementName, $parameter = null, $pageSize = 10, $page = 0)
127 127
 	{
128 128
 		$statement = $this->getSqlMapManager()->getMappedStatement($statementName);
129 129
 		return new TSqlMapPagedList($statement, $parameter, $pageSize, null, $page);
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 	 * @param integer The number of the page to initially load into the list.
145 145
 	 * @return TPagedList A PaginatedList of beans containing the rows.
146 146
 	 */
147
-	public function queryForPagedListWithRowDelegate($statementName,$delegate, $parameter=null, $pageSize=10, $page=0)
147
+	public function queryForPagedListWithRowDelegate($statementName, $delegate, $parameter = null, $pageSize = 10, $page = 0)
148 148
 	{
149 149
 		$statement = $this->getSqlMapManager()->getMappedStatement($statementName);
150
-		return new TSqlMapPagedList($statement, $parameter, $pageSize, $delegate,$page);
150
+		return new TSqlMapPagedList($statement, $parameter, $pageSize, $delegate, $page);
151 151
 	}
152 152
 
153 153
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 * @param string The property of the result object to be used as the value.
164 164
 	 * @return TMap Array object containing the rows keyed by keyProperty.
165 165
 	 */
166
-	public function queryForMap($statementName, $parameter=null, $keyProperty=null, $valueProperty=null, $skip=-1, $max=-1)
166
+	public function queryForMap($statementName, $parameter = null, $keyProperty = null, $valueProperty = null, $skip = -1, $max = -1)
167 167
 	{
168 168
 		$statement = $this->getSqlMapManager()->getMappedStatement($statementName);
169 169
 		return $statement->executeQueryForMap($this->getDbConnection(), $parameter, $keyProperty, $valueProperty, $skip, $max);
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 * @param string The property of the result object to be used as the value.
183 183
 	 * @return TMap Array object containing the rows keyed by keyProperty.
184 184
 	 */
185
-	public function queryForMapWithRowDelegate($statementName, $delegate, $parameter=null, $keyProperty=null, $valueProperty=null, $skip=-1, $max=-1)
185
+	public function queryForMapWithRowDelegate($statementName, $delegate, $parameter = null, $keyProperty = null, $valueProperty = null, $skip = -1, $max = -1)
186 186
 	{
187 187
 		$statement = $this->getSqlMapManager()->getMappedStatement($statementName);
188 188
 		return $statement->executeQueryForMap($this->getDbConnection(), $parameter, $keyProperty, $valueProperty, $skip, $max, $delegate);
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 * This might be automatically generated by the RDBMS,
205 205
 	 * or selected from a sequence table or other source.
206 206
 	 */
207
-	public function insert($statementName, $parameter=null)
207
+	public function insert($statementName, $parameter = null)
208 208
 	{
209 209
 		$statement = $this->getSqlMapManager()->getMappedStatement($statementName);
210 210
 		return $statement->executeInsert($this->getDbConnection(), $parameter);
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	 * @param mixed The parameter object.
224 224
 	 * @return integer The number of rows effected.
225 225
 	 */
226
-	public function update($statementName, $parameter=null)
226
+	public function update($statementName, $parameter = null)
227 227
 	{
228 228
 		$statement = $this->getSqlMapManager()->getMappedStatement($statementName);
229 229
 		return $statement->executeUpdate($this->getDbConnection(), $parameter);
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	 * @param mixed The parameter object.
236 236
 	 * @return integer The number of rows effected.
237 237
 	 */
238
-	public function delete($statementName, $parameter=null)
238
+	public function delete($statementName, $parameter = null)
239 239
 	{
240 240
 		return $this->update($statementName, $parameter);
241 241
 	}
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TSqlMapGateway class file.
4
- *
5
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Data.SqlMap
10
- */
3
+	 * TSqlMapGateway class file.
4
+	 *
5
+	 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
+	 * @package System.Data.SqlMap
10
+	 */
11 11
 
12 12
 Prado::using('System.Data.SqlMap.TSqlMapManager');
13 13
 
Please login to merge, or discard this patch.
framework/Data/SqlMap/TSqlMapManager.php 4 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -55,6 +55,7 @@  discard block
 block discarded – undo
55 55
 	 * Constructor, create a new SqlMap manager.
56 56
 	 * @param TDbConnection database connection
57 57
 	 * @param string configuration file.
58
+	 * @param TDbConnection $connection
58 59
 	 */
59 60
 	public function __construct($connection=null)
60 61
 	{
@@ -68,6 +69,7 @@  discard block
 block discarded – undo
68 69
 
69 70
 	/**
70 71
 	 * @param TDbConnection default database connection
72
+	 * @param TComponent $conn
71 73
 	 */
72 74
 	public function setDbConnection($conn)
73 75
 	{
@@ -105,6 +107,7 @@  discard block
 block discarded – undo
105 107
 	/**
106 108
 	 * Loads and parses the SqlMap configuration file.
107 109
 	 * @param string xml configuration file.
110
+	 * @param string $file
108 111
 	 */
109 112
 	public function configureXml($file)
110 113
 	{
@@ -180,6 +183,7 @@  discard block
 block discarded – undo
180 183
 	/**
181 184
 	 * Gets a named result map
182 185
 	 * @param string result name.
186
+	 * @param string $name
183 187
 	 * @return TResultMap the result map.
184 188
 	 * @throws TSqlMapUndefinedException
185 189
 	 */
@@ -212,6 +216,7 @@  discard block
 block discarded – undo
212 216
 
213 217
 	/**
214 218
 	 * @param string parameter map ID name.
219
+	 * @param string $name
215 220
 	 * @return TParameterMap the parameter with given ID.
216 221
 	 * @throws TSqlMapUndefinedException
217 222
 	 */
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
 	 * @param TDbConnection database connection
57 57
 	 * @param string configuration file.
58 58
 	 */
59
-	public function __construct($connection=null)
59
+	public function __construct($connection = null)
60 60
 	{
61
-		$this->_connection=$connection;
61
+		$this->_connection = $connection;
62 62
 
63
-		$this->_mappedStatements=new TMap;
64
-		$this->_resultMaps=new TMap;
65
-		$this->_parameterMaps=new TMap;
66
-		$this->_cacheModels=new TMap;
63
+		$this->_mappedStatements = new TMap;
64
+		$this->_resultMaps = new TMap;
65
+		$this->_parameterMaps = new TMap;
66
+		$this->_cacheModels = new TMap;
67 67
 	}
68 68
 
69 69
 	/**
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	public function setDbConnection($conn)
73 73
 	{
74
-		$this->_connection=$conn;
74
+		$this->_connection = $conn;
75 75
 	}
76 76
 
77 77
 	/**
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	public function getTypeHandlers()
89 89
 	{
90
-		if($this->_typeHandlers===null)
91
-			$this->_typeHandlers= new TSqlMapTypeHandlerRegistry();
90
+		if ($this->_typeHandlers === null)
91
+			$this->_typeHandlers = new TSqlMapTypeHandlerRegistry();
92 92
 		return $this->_typeHandlers;
93 93
 	}
94 94
 
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function getSqlmapGateway()
99 99
 	{
100
-		if($this->_gateway===null)
101
-			$this->_gateway=$this->createSqlMapGateway();
100
+		if ($this->_gateway === null)
101
+			$this->_gateway = $this->createSqlMapGateway();
102 102
 		return $this->_gateway;
103 103
 	}
104 104
 
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	public function getCacheDependencies()
120 120
 	{
121
-		if($this->_cacheDependencies === null)
122
-			$this->_cacheDependencies=new TChainedCacheDependency();
121
+		if ($this->_cacheDependencies === null)
122
+			$this->_cacheDependencies = new TChainedCacheDependency();
123 123
 
124 124
 		return $this->_cacheDependencies;
125 125
 	}
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 */
151 151
 	public function getMappedStatement($name)
152 152
 	{
153
-		if($this->_mappedStatements->contains($name) == false)
153
+		if ($this->_mappedStatements->contains($name) == false)
154 154
 			throw new TSqlMapUndefinedException('sqlmap_contains_no_statement', $name);
155 155
 		return $this->_mappedStatements[$name];
156 156
 	}
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	public function addMappedStatement(IMappedStatement $statement)
165 165
 	{
166 166
 		$key = $statement->getID();
167
-		if($this->_mappedStatements->contains($key) == true)
167
+		if ($this->_mappedStatements->contains($key) == true)
168 168
 			throw new TSqlMapDuplicateException('sqlmap_already_contains_statement', $key);
169 169
 		$this->_mappedStatements->add($key, $statement);
170 170
 	}
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	 */
186 186
 	public function getResultMap($name)
187 187
 	{
188
-		if($this->_resultMaps->contains($name) == false)
188
+		if ($this->_resultMaps->contains($name) == false)
189 189
 			throw new TSqlMapUndefinedException('sqlmap_contains_no_result_map', $name);
190 190
 		return $this->_resultMaps[$name];
191 191
 	}
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	public function addResultMap(TResultMap $result)
198 198
 	{
199 199
 		$key = $result->getID();
200
-		if($this->_resultMaps->contains($key) == true)
200
+		if ($this->_resultMaps->contains($key) == true)
201 201
 			throw new TSqlMapDuplicateException('sqlmap_already_contains_result_map', $key);
202 202
 		$this->_resultMaps->add($key, $result);
203 203
 	}
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	 */
218 218
 	public function getParameterMap($name)
219 219
 	{
220
-		if($this->_parameterMaps->contains($name) == false)
220
+		if ($this->_parameterMaps->contains($name) == false)
221 221
 			throw new TSqlMapUndefinedException('sqlmap_contains_no_parameter_map', $name);
222 222
 		return $this->_parameterMaps[$name];
223 223
 	}
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	public function addParameterMap(TParameterMap $parameter)
230 230
 	{
231 231
 		$key = $parameter->getID();
232
-		if($this->_parameterMaps->contains($key) == true)
232
+		if ($this->_parameterMaps->contains($key) == true)
233 233
 			throw new TSqlMapDuplicateException('sqlmap_already_contains_parameter_map', $key);
234 234
 		$this->_parameterMaps->add($key, $parameter);
235 235
 	}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 */
242 242
 	public function addCacheModel(TSqlMapCacheModel $cacheModel)
243 243
 	{
244
-		if($this->_cacheModels->contains($cacheModel->getID()))
244
+		if ($this->_cacheModels->contains($cacheModel->getID()))
245 245
 			throw new TSqlMapConfigurationException('sqlmap_cache_model_already_exists', $cacheModel->getID());
246 246
 		else
247 247
 			$this->_cacheModels->add($cacheModel->getID(), $cacheModel);
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	 */
256 256
 	public function getCacheModel($name)
257 257
 	{
258
-		if(!$this->_cacheModels->contains($name))
258
+		if (!$this->_cacheModels->contains($name))
259 259
 			throw new TSqlMapConfigurationException('sqlmap_unable_to_find_cache_model', $name);
260 260
 		return $this->_cacheModels[$name];
261 261
 	}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 	 */
266 266
 	public function flushCacheModels()
267 267
 	{
268
-		foreach($this->_cacheModels as $cache)
268
+		foreach ($this->_cacheModels as $cache)
269 269
 			$cache->flush();
270 270
 	}
271 271
 }
Please login to merge, or discard this patch.
Braces   +38 added lines, -26 removed lines patch added patch discarded remove patch
@@ -87,8 +87,9 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	public function getTypeHandlers()
89 89
 	{
90
-		if($this->_typeHandlers===null)
91
-			$this->_typeHandlers= new TSqlMapTypeHandlerRegistry();
90
+		if($this->_typeHandlers===null) {
91
+					$this->_typeHandlers= new TSqlMapTypeHandlerRegistry();
92
+		}
92 93
 		return $this->_typeHandlers;
93 94
 	}
94 95
 
@@ -97,8 +98,9 @@  discard block
 block discarded – undo
97 98
 	 */
98 99
 	public function getSqlmapGateway()
99 100
 	{
100
-		if($this->_gateway===null)
101
-			$this->_gateway=$this->createSqlMapGateway();
101
+		if($this->_gateway===null) {
102
+					$this->_gateway=$this->createSqlMapGateway();
103
+		}
102 104
 		return $this->_gateway;
103 105
 	}
104 106
 
@@ -118,8 +120,9 @@  discard block
 block discarded – undo
118 120
 	 */
119 121
 	public function getCacheDependencies()
120 122
 	{
121
-		if($this->_cacheDependencies === null)
122
-			$this->_cacheDependencies=new TChainedCacheDependency();
123
+		if($this->_cacheDependencies === null) {
124
+					$this->_cacheDependencies=new TChainedCacheDependency();
125
+		}
123 126
 
124 127
 		return $this->_cacheDependencies;
125 128
 	}
@@ -150,8 +153,9 @@  discard block
 block discarded – undo
150 153
 	 */
151 154
 	public function getMappedStatement($name)
152 155
 	{
153
-		if($this->_mappedStatements->contains($name) == false)
154
-			throw new TSqlMapUndefinedException('sqlmap_contains_no_statement', $name);
156
+		if($this->_mappedStatements->contains($name) == false) {
157
+					throw new TSqlMapUndefinedException('sqlmap_contains_no_statement', $name);
158
+		}
155 159
 		return $this->_mappedStatements[$name];
156 160
 	}
157 161
 
@@ -164,8 +168,9 @@  discard block
 block discarded – undo
164 168
 	public function addMappedStatement(IMappedStatement $statement)
165 169
 	{
166 170
 		$key = $statement->getID();
167
-		if($this->_mappedStatements->contains($key) == true)
168
-			throw new TSqlMapDuplicateException('sqlmap_already_contains_statement', $key);
171
+		if($this->_mappedStatements->contains($key) == true) {
172
+					throw new TSqlMapDuplicateException('sqlmap_already_contains_statement', $key);
173
+		}
169 174
 		$this->_mappedStatements->add($key, $statement);
170 175
 	}
171 176
 
@@ -185,8 +190,9 @@  discard block
 block discarded – undo
185 190
 	 */
186 191
 	public function getResultMap($name)
187 192
 	{
188
-		if($this->_resultMaps->contains($name) == false)
189
-			throw new TSqlMapUndefinedException('sqlmap_contains_no_result_map', $name);
193
+		if($this->_resultMaps->contains($name) == false) {
194
+					throw new TSqlMapUndefinedException('sqlmap_contains_no_result_map', $name);
195
+		}
190 196
 		return $this->_resultMaps[$name];
191 197
 	}
192 198
 
@@ -197,8 +203,9 @@  discard block
 block discarded – undo
197 203
 	public function addResultMap(TResultMap $result)
198 204
 	{
199 205
 		$key = $result->getID();
200
-		if($this->_resultMaps->contains($key) == true)
201
-			throw new TSqlMapDuplicateException('sqlmap_already_contains_result_map', $key);
206
+		if($this->_resultMaps->contains($key) == true) {
207
+					throw new TSqlMapDuplicateException('sqlmap_already_contains_result_map', $key);
208
+		}
202 209
 		$this->_resultMaps->add($key, $result);
203 210
 	}
204 211
 
@@ -217,8 +224,9 @@  discard block
 block discarded – undo
217 224
 	 */
218 225
 	public function getParameterMap($name)
219 226
 	{
220
-		if($this->_parameterMaps->contains($name) == false)
221
-			throw new TSqlMapUndefinedException('sqlmap_contains_no_parameter_map', $name);
227
+		if($this->_parameterMaps->contains($name) == false) {
228
+					throw new TSqlMapUndefinedException('sqlmap_contains_no_parameter_map', $name);
229
+		}
222 230
 		return $this->_parameterMaps[$name];
223 231
 	}
224 232
 
@@ -229,8 +237,9 @@  discard block
 block discarded – undo
229 237
 	public function addParameterMap(TParameterMap $parameter)
230 238
 	{
231 239
 		$key = $parameter->getID();
232
-		if($this->_parameterMaps->contains($key) == true)
233
-			throw new TSqlMapDuplicateException('sqlmap_already_contains_parameter_map', $key);
240
+		if($this->_parameterMaps->contains($key) == true) {
241
+					throw new TSqlMapDuplicateException('sqlmap_already_contains_parameter_map', $key);
242
+		}
234 243
 		$this->_parameterMaps->add($key, $parameter);
235 244
 	}
236 245
 
@@ -241,10 +250,11 @@  discard block
 block discarded – undo
241 250
 	 */
242 251
 	public function addCacheModel(TSqlMapCacheModel $cacheModel)
243 252
 	{
244
-		if($this->_cacheModels->contains($cacheModel->getID()))
245
-			throw new TSqlMapConfigurationException('sqlmap_cache_model_already_exists', $cacheModel->getID());
246
-		else
247
-			$this->_cacheModels->add($cacheModel->getID(), $cacheModel);
253
+		if($this->_cacheModels->contains($cacheModel->getID())) {
254
+					throw new TSqlMapConfigurationException('sqlmap_cache_model_already_exists', $cacheModel->getID());
255
+		} else {
256
+					$this->_cacheModels->add($cacheModel->getID(), $cacheModel);
257
+		}
248 258
 	}
249 259
 
250 260
 	/**
@@ -255,8 +265,9 @@  discard block
 block discarded – undo
255 265
 	 */
256 266
 	public function getCacheModel($name)
257 267
 	{
258
-		if(!$this->_cacheModels->contains($name))
259
-			throw new TSqlMapConfigurationException('sqlmap_unable_to_find_cache_model', $name);
268
+		if(!$this->_cacheModels->contains($name)) {
269
+					throw new TSqlMapConfigurationException('sqlmap_unable_to_find_cache_model', $name);
270
+		}
260 271
 		return $this->_cacheModels[$name];
261 272
 	}
262 273
 
@@ -265,8 +276,9 @@  discard block
 block discarded – undo
265 276
 	 */
266 277
 	public function flushCacheModels()
267 278
 	{
268
-		foreach($this->_cacheModels as $cache)
269
-			$cache->flush();
279
+		foreach($this->_cacheModels as $cache) {
280
+					$cache->flush();
281
+		}
270 282
 	}
271 283
 }
272 284
 
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TSqlMapManager class file.
4
- *
5
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Data.SqlMap
10
- */
3
+	 * TSqlMapManager class file.
4
+	 *
5
+	 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
+	 * @package System.Data.SqlMap
10
+	 */
11 11
 
12 12
 Prado::using('System.Data.SqlMap.TSqlMapGateway');
13 13
 Prado::using('System.Data.SqlMap.DataMapper.TSqlMapException');
Please login to merge, or discard this patch.
framework/Data/TDataSourceConfig.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -149,6 +149,7 @@
 block discarded – undo
149 149
 	/**
150 150
 	 * Finds the database connection instance from the Application modules.
151 151
 	 * @param string Database connection module ID.
152
+	 * @param string $id
152 153
 	 * @return TDbConnection database connection.
153 154
 	 * @throws TConfigurationException when module is not of TDbConnection or TDataSourceConfig.
154 155
 	 */
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
  */
47 47
 class TDataSourceConfig extends TModule
48 48
 {
49
-	private $_connID='';
49
+	private $_connID = '';
50 50
 	private $_conn;
51
-	private $_connClass='System.Data.TDbConnection';
51
+	private $_connClass = 'System.Data.TDbConnection';
52 52
 
53 53
 	/**
54 54
 	 * Initalize the database connection properties from attributes in <database> tag.
@@ -56,22 +56,22 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function init($xml)
58 58
 	{
59
-		if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
59
+		if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
60 60
 		{
61
-			if(isset($xml['database']) && is_array($xml['database']))
61
+			if (isset($xml['database']) && is_array($xml['database']))
62 62
 			{
63
-				$db=$this->getDbConnection();
64
-				foreach($xml['database'] as $name=>$value)
65
-					$db->setSubProperty($name,$value);
63
+				$db = $this->getDbConnection();
64
+				foreach ($xml['database'] as $name=>$value)
65
+					$db->setSubProperty($name, $value);
66 66
 			}
67 67
 		}
68 68
 		else
69 69
 		{
70
-			if($prop=$xml->getElementByTagName('database'))
70
+			if ($prop = $xml->getElementByTagName('database'))
71 71
 			{
72
-				$db=$this->getDbConnection();
73
-				foreach($prop->getAttributes() as $name=>$value)
74
-					$db->setSubproperty($name,$value);
72
+				$db = $this->getDbConnection();
73
+				foreach ($prop->getAttributes() as $name=>$value)
74
+					$db->setSubproperty($name, $value);
75 75
 			}
76 76
 		}
77 77
 	}
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	public function setConnectionID($value)
86 86
 	{
87
-		$this->_connID=$value;
87
+		$this->_connID = $value;
88 88
 	}
89 89
 
90 90
 	/**
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	public function getDbConnection()
105 105
 	{
106
-		if($this->_conn===null)
106
+		if ($this->_conn === null)
107 107
 		{
108
-			if($this->_connID!=='')
108
+			if ($this->_connID !== '')
109 109
 				$this->_conn = $this->findConnectionByID($this->getConnectionID());
110 110
 			else
111 111
 				$this->_conn = Prado::createComponent($this->getConnectionClass());
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public function setConnectionClass($value)
143 143
 	{
144
-		if($this->_conn!==null)
144
+		if ($this->_conn !== null)
145 145
 			throw new TConfigurationException('datasource_dbconnection_exists', $value);
146
-		$this->_connClass=$value;
146
+		$this->_connClass = $value;
147 147
 	}
148 148
 
149 149
 	/**
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
 	protected function findConnectionByID($id)
156 156
 	{
157 157
 		$conn = $this->getApplication()->getModule($id);
158
-		if($conn instanceof TDbConnection)
158
+		if ($conn instanceof TDbConnection)
159 159
 			return $conn;
160
-		else if($conn instanceof TDataSourceConfig)
160
+		else if ($conn instanceof TDataSourceConfig)
161 161
 			return $conn->getDbConnection();
162 162
 		else
163
-			throw new TConfigurationException('datasource_dbconnection_invalid',$id);
163
+			throw new TConfigurationException('datasource_dbconnection_invalid', $id);
164 164
 	}
165 165
 }
Please login to merge, or discard this patch.
Braces   +22 added lines, -18 removed lines patch added patch discarded remove patch
@@ -61,17 +61,18 @@  discard block
 block discarded – undo
61 61
 			if(isset($xml['database']) && is_array($xml['database']))
62 62
 			{
63 63
 				$db=$this->getDbConnection();
64
-				foreach($xml['database'] as $name=>$value)
65
-					$db->setSubProperty($name,$value);
64
+				foreach($xml['database'] as $name=>$value) {
65
+									$db->setSubProperty($name,$value);
66
+				}
66 67
 			}
67
-		}
68
-		else
68
+		} else
69 69
 		{
70 70
 			if($prop=$xml->getElementByTagName('database'))
71 71
 			{
72 72
 				$db=$this->getDbConnection();
73
-				foreach($prop->getAttributes() as $name=>$value)
74
-					$db->setSubproperty($name,$value);
73
+				foreach($prop->getAttributes() as $name=>$value) {
74
+									$db->setSubproperty($name,$value);
75
+				}
75 76
 			}
76 77
 		}
77 78
 	}
@@ -105,10 +106,11 @@  discard block
 block discarded – undo
105 106
 	{
106 107
 		if($this->_conn===null)
107 108
 		{
108
-			if($this->_connID!=='')
109
-				$this->_conn = $this->findConnectionByID($this->getConnectionID());
110
-			else
111
-				$this->_conn = Prado::createComponent($this->getConnectionClass());
109
+			if($this->_connID!=='') {
110
+							$this->_conn = $this->findConnectionByID($this->getConnectionID());
111
+			} else {
112
+							$this->_conn = Prado::createComponent($this->getConnectionClass());
113
+			}
112 114
 		}
113 115
 		return $this->_conn;
114 116
 	}
@@ -141,8 +143,9 @@  discard block
 block discarded – undo
141 143
 	 */
142 144
 	public function setConnectionClass($value)
143 145
 	{
144
-		if($this->_conn!==null)
145
-			throw new TConfigurationException('datasource_dbconnection_exists', $value);
146
+		if($this->_conn!==null) {
147
+					throw new TConfigurationException('datasource_dbconnection_exists', $value);
148
+		}
146 149
 		$this->_connClass=$value;
147 150
 	}
148 151
 
@@ -155,11 +158,12 @@  discard block
 block discarded – undo
155 158
 	protected function findConnectionByID($id)
156 159
 	{
157 160
 		$conn = $this->getApplication()->getModule($id);
158
-		if($conn instanceof TDbConnection)
159
-			return $conn;
160
-		else if($conn instanceof TDataSourceConfig)
161
-			return $conn->getDbConnection();
162
-		else
163
-			throw new TConfigurationException('datasource_dbconnection_invalid',$id);
161
+		if($conn instanceof TDbConnection) {
162
+					return $conn;
163
+		} else if($conn instanceof TDataSourceConfig) {
164
+					return $conn->getDbConnection();
165
+		} else {
166
+					throw new TConfigurationException('datasource_dbconnection_invalid',$id);
167
+		}
164 168
 	}
165 169
 }
Please login to merge, or discard this patch.
framework/Data/TDbCommand.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -136,6 +136,7 @@
 block discarded – undo
136 136
 	 * @param mixed Name of the PHP variable to bind to the SQL statement parameter
137 137
 	 * @param int SQL data type of the parameter
138 138
 	 * @param int length of the data type
139
+	 * @param string $name
139 140
 	 * @see http://www.php.net/manual/en/function.PDOStatement-bindParam.php
140 141
 	 */
141 142
 	public function bindParameter($name, &$value, $dataType=null, $length=null)
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -37,17 +37,17 @@  discard block
 block discarded – undo
37 37
 class TDbCommand extends TComponent
38 38
 {
39 39
 	private $_connection;
40
-	private $_text='';
41
-	private $_statement=null;
40
+	private $_text = '';
41
+	private $_statement = null;
42 42
 
43 43
 	/**
44 44
 	 * Constructor.
45 45
 	 * @param TDbConnection the database connection
46 46
 	 * @param string the SQL statement to be executed
47 47
 	 */
48
-	public function __construct(TDbConnection $connection,$text)
48
+	public function __construct(TDbConnection $connection, $text)
49 49
 	{
50
-		$this->_connection=$connection;
50
+		$this->_connection = $connection;
51 51
 		$this->setText($text);
52 52
 	}
53 53
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function __sleep()
58 58
 	{
59
-		return array_diff(parent::__sleep(),array("\0TDbCommand\0_statement"));
59
+		return array_diff(parent::__sleep(), array("\0TDbCommand\0_statement"));
60 60
 	}
61 61
 
62 62
 	/**
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	public function setText($value)
76 76
 	{
77
-		$this->_text=$value;
77
+		$this->_text = $value;
78 78
 		$this->cancel();
79 79
 	}
80 80
 
@@ -104,15 +104,15 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	public function prepare()
106 106
 	{
107
-		if($this->_statement==null)
107
+		if ($this->_statement == null)
108 108
 		{
109 109
 			try
110 110
 			{
111
-				$this->_statement=$this->getConnection()->getPdoInstance()->prepare($this->getText());
111
+				$this->_statement = $this->getConnection()->getPdoInstance()->prepare($this->getText());
112 112
 			}
113
-			catch(Exception $e)
113
+			catch (Exception $e)
114 114
 			{
115
-				throw new TDbException('dbcommand_prepare_failed',$e->getMessage(),$this->getText());
115
+				throw new TDbException('dbcommand_prepare_failed', $e->getMessage(), $this->getText());
116 116
 			}
117 117
 		}
118 118
 	}
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	public function cancel()
124 124
 	{
125
-		$this->_statement=null;
125
+		$this->_statement = null;
126 126
 	}
127 127
 
128 128
 	/**
@@ -138,15 +138,15 @@  discard block
 block discarded – undo
138 138
 	 * @param int length of the data type
139 139
 	 * @see http://www.php.net/manual/en/function.PDOStatement-bindParam.php
140 140
 	 */
141
-	public function bindParameter($name, &$value, $dataType=null, $length=null)
141
+	public function bindParameter($name, &$value, $dataType = null, $length = null)
142 142
 	{
143 143
 		$this->prepare();
144
-		if($dataType===null)
145
-			$this->_statement->bindParam($name,$value);
146
-		else if($length===null)
147
-			$this->_statement->bindParam($name,$value,$dataType);
144
+		if ($dataType === null)
145
+			$this->_statement->bindParam($name, $value);
146
+		else if ($length === null)
147
+			$this->_statement->bindParam($name, $value, $dataType);
148 148
 		else
149
-			$this->_statement->bindParam($name,$value,$dataType,$length);
149
+			$this->_statement->bindParam($name, $value, $dataType, $length);
150 150
 	}
151 151
 
152 152
 	/**
@@ -159,13 +159,13 @@  discard block
 block discarded – undo
159 159
 	 * @param int SQL data type of the parameter
160 160
 	 * @see http://www.php.net/manual/en/function.PDOStatement-bindValue.php
161 161
 	 */
162
-	public function bindValue($name, $value, $dataType=null)
162
+	public function bindValue($name, $value, $dataType = null)
163 163
 	{
164 164
 		$this->prepare();
165
-		if($dataType===null)
166
-			$this->_statement->bindValue($name,$value);
165
+		if ($dataType === null)
166
+			$this->_statement->bindValue($name, $value);
167 167
 		else
168
-			$this->_statement->bindValue($name,$value,$dataType);
168
+			$this->_statement->bindValue($name, $value, $dataType);
169 169
 	}
170 170
 
171 171
 	/**
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 			// Do not trace because it will remain even in
183 183
 			// Performance mode or when pradolite.php is used
184 184
 			// Prado::trace('Execute Command: '.$this->getDebugStatementText(), 'System.Data');
185
-			if($this->_statement instanceof PDOStatement)
185
+			if ($this->_statement instanceof PDOStatement)
186 186
 			{
187 187
 				$this->_statement->execute();
188 188
 				return $this->_statement->rowCount();
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
 			else
191 191
 				return $this->getConnection()->getPdoInstance()->exec($this->getText());
192 192
 		}
193
-		catch(Exception $e)
193
+		catch (Exception $e)
194 194
 		{
195
-			throw new TDbException('dbcommand_execute_failed',$e->getMessage(),$this->getDebugStatementText());
195
+			throw new TDbException('dbcommand_execute_failed', $e->getMessage(), $this->getDebugStatementText());
196 196
 		}
197 197
 	}
198 198
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 */
202 202
 	public function getDebugStatementText()
203 203
 	{
204
-		if(Prado::getApplication()->getMode() === TApplicationMode::Debug)
204
+		if (Prado::getApplication()->getMode() === TApplicationMode::Debug)
205 205
 			return $this->_statement instanceof PDOStatement ?
206 206
 				$this->_statement->queryString
207 207
 				: $this->getText();
@@ -218,15 +218,15 @@  discard block
 block discarded – undo
218 218
 		try
219 219
 		{
220 220
 			// Prado::trace('Query: '.$this->getDebugStatementText(), 'System.Data');
221
-			if($this->_statement instanceof PDOStatement)
221
+			if ($this->_statement instanceof PDOStatement)
222 222
 				$this->_statement->execute();
223 223
 			else
224
-				$this->_statement=$this->getConnection()->getPdoInstance()->query($this->getText());
224
+				$this->_statement = $this->getConnection()->getPdoInstance()->query($this->getText());
225 225
 			return new TDbDataReader($this);
226 226
 		}
227
-		catch(Exception $e)
227
+		catch (Exception $e)
228 228
 		{
229
-			throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText());
229
+			throw new TDbException('dbcommand_query_failed', $e->getMessage(), $this->getDebugStatementText());
230 230
 		}
231 231
 	}
232 232
 
@@ -238,22 +238,22 @@  discard block
 block discarded – undo
238 238
 	 * @return array the first row of the query result, false if no result.
239 239
 	 * @throws TDbException execution failed
240 240
 	 */
241
-	public function queryRow($fetchAssociative=true)
241
+	public function queryRow($fetchAssociative = true)
242 242
 	{
243 243
 		try
244 244
 		{
245 245
 			// Prado::trace('Query Row: '.$this->getDebugStatementText(), 'System.Data');
246
-			if($this->_statement instanceof PDOStatement)
246
+			if ($this->_statement instanceof PDOStatement)
247 247
 				$this->_statement->execute();
248 248
 			else
249
-				$this->_statement=$this->getConnection()->getPdoInstance()->query($this->getText());
250
-			$result=$this->_statement->fetch($fetchAssociative ? PDO::FETCH_ASSOC : PDO::FETCH_NUM);
249
+				$this->_statement = $this->getConnection()->getPdoInstance()->query($this->getText());
250
+			$result = $this->_statement->fetch($fetchAssociative ? PDO::FETCH_ASSOC : PDO::FETCH_NUM);
251 251
 			$this->_statement->closeCursor();
252 252
 			return $result;
253 253
 		}
254
-		catch(Exception $e)
254
+		catch (Exception $e)
255 255
 		{
256
-			throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText());
256
+			throw new TDbException('dbcommand_query_failed', $e->getMessage(), $this->getDebugStatementText());
257 257
 		}
258 258
 	}
259 259
 
@@ -269,20 +269,20 @@  discard block
 block discarded – undo
269 269
 		try
270 270
 		{
271 271
 			// Prado::trace('Query Scalar: '.$this->getDebugStatementText(), 'System.Data');
272
-			if($this->_statement instanceof PDOStatement)
272
+			if ($this->_statement instanceof PDOStatement)
273 273
 				$this->_statement->execute();
274 274
 			else
275
-				$this->_statement=$this->getConnection()->getPdoInstance()->query($this->getText());
276
-			$result=$this->_statement->fetchColumn();
275
+				$this->_statement = $this->getConnection()->getPdoInstance()->query($this->getText());
276
+			$result = $this->_statement->fetchColumn();
277 277
 			$this->_statement->closeCursor();
278
-			if(is_resource($result) && get_resource_type($result)==='stream')
278
+			if (is_resource($result) && get_resource_type($result) === 'stream')
279 279
 				return stream_get_contents($result);
280 280
 			else
281 281
 				return $result;
282 282
 		}
283
-		catch(Exception $e)
283
+		catch (Exception $e)
284 284
 		{
285
-			throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText());
285
+			throw new TDbException('dbcommand_query_failed', $e->getMessage(), $this->getDebugStatementText());
286 286
 		}
287 287
 	}
288 288
 
@@ -296,10 +296,10 @@  discard block
 block discarded – undo
296 296
 	 */
297 297
 	public function queryColumn()
298 298
 	{
299
-		$rows=$this->query()->readAll();
300
-		$column=array();
301
-		foreach($rows as $row)
302
-			$column[]=current($row);
299
+		$rows = $this->query()->readAll();
300
+		$column = array();
301
+		foreach ($rows as $row)
302
+			$column[] = current($row);
303 303
 		return $column;
304 304
 	}
305 305
 }
Please login to merge, or discard this patch.
Braces   +45 added lines, -42 removed lines patch added patch discarded remove patch
@@ -109,8 +109,7 @@  discard block
 block discarded – undo
109 109
 			try
110 110
 			{
111 111
 				$this->_statement=$this->getConnection()->getPdoInstance()->prepare($this->getText());
112
-			}
113
-			catch(Exception $e)
112
+			} catch(Exception $e)
114 113
 			{
115 114
 				throw new TDbException('dbcommand_prepare_failed',$e->getMessage(),$this->getText());
116 115
 			}
@@ -141,12 +140,13 @@  discard block
 block discarded – undo
141 140
 	public function bindParameter($name, &$value, $dataType=null, $length=null)
142 141
 	{
143 142
 		$this->prepare();
144
-		if($dataType===null)
145
-			$this->_statement->bindParam($name,$value);
146
-		else if($length===null)
147
-			$this->_statement->bindParam($name,$value,$dataType);
148
-		else
149
-			$this->_statement->bindParam($name,$value,$dataType,$length);
143
+		if($dataType===null) {
144
+					$this->_statement->bindParam($name,$value);
145
+		} else if($length===null) {
146
+					$this->_statement->bindParam($name,$value,$dataType);
147
+		} else {
148
+					$this->_statement->bindParam($name,$value,$dataType,$length);
149
+		}
150 150
 	}
151 151
 
152 152
 	/**
@@ -162,10 +162,11 @@  discard block
 block discarded – undo
162 162
 	public function bindValue($name, $value, $dataType=null)
163 163
 	{
164 164
 		$this->prepare();
165
-		if($dataType===null)
166
-			$this->_statement->bindValue($name,$value);
167
-		else
168
-			$this->_statement->bindValue($name,$value,$dataType);
165
+		if($dataType===null) {
166
+					$this->_statement->bindValue($name,$value);
167
+		} else {
168
+					$this->_statement->bindValue($name,$value,$dataType);
169
+		}
169 170
 	}
170 171
 
171 172
 	/**
@@ -186,11 +187,10 @@  discard block
 block discarded – undo
186 187
 			{
187 188
 				$this->_statement->execute();
188 189
 				return $this->_statement->rowCount();
190
+			} else {
191
+							return $this->getConnection()->getPdoInstance()->exec($this->getText());
189 192
 			}
190
-			else
191
-				return $this->getConnection()->getPdoInstance()->exec($this->getText());
192
-		}
193
-		catch(Exception $e)
193
+		} catch(Exception $e)
194 194
 		{
195 195
 			throw new TDbException('dbcommand_execute_failed',$e->getMessage(),$this->getDebugStatementText());
196 196
 		}
@@ -201,10 +201,11 @@  discard block
 block discarded – undo
201 201
 	 */
202 202
 	public function getDebugStatementText()
203 203
 	{
204
-		if(Prado::getApplication()->getMode() === TApplicationMode::Debug)
205
-			return $this->_statement instanceof PDOStatement ?
204
+		if(Prado::getApplication()->getMode() === TApplicationMode::Debug) {
205
+					return $this->_statement instanceof PDOStatement ?
206 206
 				$this->_statement->queryString
207 207
 				: $this->getText();
208
+		}
208 209
 	}
209 210
 
210 211
 	/**
@@ -218,13 +219,13 @@  discard block
 block discarded – undo
218 219
 		try
219 220
 		{
220 221
 			// Prado::trace('Query: '.$this->getDebugStatementText(), 'System.Data');
221
-			if($this->_statement instanceof PDOStatement)
222
-				$this->_statement->execute();
223
-			else
224
-				$this->_statement=$this->getConnection()->getPdoInstance()->query($this->getText());
222
+			if($this->_statement instanceof PDOStatement) {
223
+							$this->_statement->execute();
224
+			} else {
225
+							$this->_statement=$this->getConnection()->getPdoInstance()->query($this->getText());
226
+			}
225 227
 			return new TDbDataReader($this);
226
-		}
227
-		catch(Exception $e)
228
+		} catch(Exception $e)
228 229
 		{
229 230
 			throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText());
230 231
 		}
@@ -243,15 +244,15 @@  discard block
 block discarded – undo
243 244
 		try
244 245
 		{
245 246
 			// Prado::trace('Query Row: '.$this->getDebugStatementText(), 'System.Data');
246
-			if($this->_statement instanceof PDOStatement)
247
-				$this->_statement->execute();
248
-			else
249
-				$this->_statement=$this->getConnection()->getPdoInstance()->query($this->getText());
247
+			if($this->_statement instanceof PDOStatement) {
248
+							$this->_statement->execute();
249
+			} else {
250
+							$this->_statement=$this->getConnection()->getPdoInstance()->query($this->getText());
251
+			}
250 252
 			$result=$this->_statement->fetch($fetchAssociative ? PDO::FETCH_ASSOC : PDO::FETCH_NUM);
251 253
 			$this->_statement->closeCursor();
252 254
 			return $result;
253
-		}
254
-		catch(Exception $e)
255
+		} catch(Exception $e)
255 256
 		{
256 257
 			throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText());
257 258
 		}
@@ -269,18 +270,19 @@  discard block
 block discarded – undo
269 270
 		try
270 271
 		{
271 272
 			// Prado::trace('Query Scalar: '.$this->getDebugStatementText(), 'System.Data');
272
-			if($this->_statement instanceof PDOStatement)
273
-				$this->_statement->execute();
274
-			else
275
-				$this->_statement=$this->getConnection()->getPdoInstance()->query($this->getText());
273
+			if($this->_statement instanceof PDOStatement) {
274
+							$this->_statement->execute();
275
+			} else {
276
+							$this->_statement=$this->getConnection()->getPdoInstance()->query($this->getText());
277
+			}
276 278
 			$result=$this->_statement->fetchColumn();
277 279
 			$this->_statement->closeCursor();
278
-			if(is_resource($result) && get_resource_type($result)==='stream')
279
-				return stream_get_contents($result);
280
-			else
281
-				return $result;
282
-		}
283
-		catch(Exception $e)
280
+			if(is_resource($result) && get_resource_type($result)==='stream') {
281
+							return stream_get_contents($result);
282
+			} else {
283
+							return $result;
284
+			}
285
+		} catch(Exception $e)
284 286
 		{
285 287
 			throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText());
286 288
 		}
@@ -298,8 +300,9 @@  discard block
 block discarded – undo
298 300
 	{
299 301
 		$rows=$this->query()->readAll();
300 302
 		$column=array();
301
-		foreach($rows as $row)
302
-			$column[]=current($row);
303
+		foreach($rows as $row) {
304
+					$column[]=current($row);
305
+		}
303 306
 		return $column;
304 307
 	}
305 308
 }
Please login to merge, or discard this patch.
framework/Data/TDbConnection.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -157,6 +157,7 @@  discard block
 block discarded – undo
157 157
 	/**
158 158
 	 * Open or close the DB connection.
159 159
 	 * @param boolean whether to open or close DB connection
160
+	 * @param boolean $value
160 161
 	 * @throws TDbException if connection fails
161 162
 	 */
162 163
 	public function setActive($value)
@@ -241,6 +242,7 @@  discard block
 block discarded – undo
241 242
 
242 243
 	/**
243 244
 	 * @param string The Data Source Name, or DSN, contains the information required to connect to the database.
245
+	 * @param string $value
244 246
 	 * @see http://www.php.net/manual/en/function.PDO-construct.php
245 247
 	 */
246 248
 	public function setConnectionString($value)
@@ -258,6 +260,7 @@  discard block
 block discarded – undo
258 260
 
259 261
 	/**
260 262
 	 * @param string the username for establishing DB connection
263
+	 * @param string $value
261 264
 	 */
262 265
 	public function setUsername($value)
263 266
 	{
@@ -274,6 +277,7 @@  discard block
 block discarded – undo
274 277
 
275 278
 	/**
276 279
 	 * @param string the password for establishing DB connection
280
+	 * @param string $value
277 281
 	 */
278 282
 	public function setPassword($value)
279 283
 	{
Please login to merge, or discard this patch.
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -87,13 +87,13 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	const DEFAULT_TRANSACTION_CLASS = 'System.Data.TDbTransaction';
89 89
 
90
-	private $_dsn='';
91
-	private $_username='';
92
-	private $_password='';
93
-	private $_charset='';
94
-	private $_attributes=array();
95
-	private $_active=false;
96
-	private $_pdo=null;
90
+	private $_dsn = '';
91
+	private $_username = '';
92
+	private $_password = '';
93
+	private $_charset = '';
94
+	private $_attributes = array();
95
+	private $_active = false;
96
+	private $_pdo = null;
97 97
 	private $_transaction;
98 98
 
99 99
 	/**
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * @var string
106 106
 	 * @since 3.1.7
107 107
 	 */
108
-	private $_transactionClass=self::DEFAULT_TRANSACTION_CLASS;
108
+	private $_transactionClass = self::DEFAULT_TRANSACTION_CLASS;
109 109
 
110 110
 	/**
111 111
 	 * Constructor.
@@ -120,12 +120,12 @@  discard block
 block discarded – undo
120 120
 	 * @param string Charset used for DB Connection (MySql & pgsql only). If not set, will use the default charset of your database server
121 121
 	 * @see http://www.php.net/manual/en/function.PDO-construct.php
122 122
 	 */
123
-	public function __construct($dsn='',$username='',$password='', $charset='')
123
+	public function __construct($dsn = '', $username = '', $password = '', $charset = '')
124 124
 	{
125
-		$this->_dsn=$dsn;
126
-		$this->_username=$username;
127
-		$this->_password=$password;
128
-		$this->_charset=$charset;
125
+		$this->_dsn = $dsn;
126
+		$this->_username = $username;
127
+		$this->_password = $password;
128
+		$this->_charset = $charset;
129 129
 	}
130 130
 
131 131
 	/**
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	public function __sleep()
135 135
 	{
136 136
 //		$this->close(); - DO NOT CLOSE the current connection as serializing doesn't neccessarily mean we don't this connection anymore in the current session
137
-		return array_diff(parent::__sleep(),array("\0TDbConnection\0_pdo","\0TDbConnection\0_active"));
137
+		return array_diff(parent::__sleep(), array("\0TDbConnection\0_pdo", "\0TDbConnection\0_active"));
138 138
 	}
139 139
 
140 140
 	/**
@@ -161,10 +161,10 @@  discard block
 block discarded – undo
161 161
 	 */
162 162
 	public function setActive($value)
163 163
 	{
164
-		$value=TPropertyValue::ensureBoolean($value);
165
-		if($value!==$this->_active)
164
+		$value = TPropertyValue::ensureBoolean($value);
165
+		if ($value !== $this->_active)
166 166
 		{
167
-			if($value)
167
+			if ($value)
168 168
 				$this->open();
169 169
 			else
170 170
 				$this->close();
@@ -177,22 +177,22 @@  discard block
 block discarded – undo
177 177
 	 */
178 178
 	protected function open()
179 179
 	{
180
-		if($this->_pdo===null)
180
+		if ($this->_pdo === null)
181 181
 		{
182 182
 			try
183 183
 			{
184
-				$this->_pdo=new PDO($this->getConnectionString(),$this->getUsername(),
185
-									$this->getPassword(),$this->_attributes);
184
+				$this->_pdo = new PDO($this->getConnectionString(), $this->getUsername(),
185
+									$this->getPassword(), $this->_attributes);
186 186
 				// This attribute is only useful for PDO::MySql driver.
187 187
 				// Ignore the warning if a driver doesn't understand this.
188 188
 				@$this->_pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
189 189
 				$this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
190
-				$this->_active=true;
190
+				$this->_active = true;
191 191
 				$this->setConnectionCharset();
192 192
 			}
193
-			catch(PDOException $e)
193
+			catch (PDOException $e)
194 194
 			{
195
-				throw new TDbException('dbconnection_open_failed',$e->getMessage());
195
+				throw new TDbException('dbconnection_open_failed', $e->getMessage());
196 196
 			}
197 197
 		}
198 198
 	}
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
 	 */
204 204
 	protected function close()
205 205
 	{
206
-		$this->_pdo=null;
207
-		$this->_active=false;
206
+		$this->_pdo = null;
207
+		$this->_active = false;
208 208
 	}
209 209
 
210 210
 	/*
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 */
246 246
 	public function setConnectionString($value)
247 247
 	{
248
-		$this->_dsn=$value;
248
+		$this->_dsn = $value;
249 249
 	}
250 250
 
251 251
 	/**
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	public function setUsername($value)
263 263
 	{
264
-		$this->_username=$value;
264
+		$this->_username = $value;
265 265
 	}
266 266
 
267 267
 	/**
@@ -277,13 +277,13 @@  discard block
 block discarded – undo
277 277
 	 */
278 278
 	public function setPassword($value)
279 279
 	{
280
-		$this->_password=$value;
280
+		$this->_password = $value;
281 281
 	}
282 282
 
283 283
 	/**
284 284
 	 * @return string the charset used for database connection. Defaults to emtpy string.
285 285
 	 */
286
-	public function getCharset ()
286
+	public function getCharset()
287 287
 	{
288 288
 		return $this->_charset;
289 289
 	}
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
 	/**
292 292
 	 * @param string the charset used for database connection
293 293
 	 */
294
-	public function setCharset ($value)
294
+	public function setCharset($value)
295 295
 	{
296
-		$this->_charset=$value;
296
+		$this->_charset = $value;
297 297
 		$this->setConnectionCharset();
298 298
 	}
299 299
 
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
 	 */
314 314
 	public function createCommand($sql)
315 315
 	{
316
-		if($this->getActive())
317
-			return new TDbCommand($this,$sql);
316
+		if ($this->getActive())
317
+			return new TDbCommand($this, $sql);
318 318
 		else
319 319
 			throw new TDbException('dbconnection_connection_inactive');
320 320
 	}
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
 	 */
325 325
 	public function getCurrentTransaction()
326 326
 	{
327
-		if($this->_transaction!==null)
327
+		if ($this->_transaction !== null)
328 328
 		{
329
-			if($this->_transaction->getActive())
329
+			if ($this->_transaction->getActive())
330 330
 				return $this->_transaction;
331 331
 		}
332 332
 		return null;
@@ -339,10 +339,10 @@  discard block
 block discarded – undo
339 339
 	 */
340 340
 	public function beginTransaction()
341 341
 	{
342
-		if($this->getActive())
342
+		if ($this->getActive())
343 343
 		{
344 344
 			$this->_pdo->beginTransaction();
345
-			return $this->_transaction=Prado::createComponent($this->getTransactionClass(), $this);
345
+			return $this->_transaction = Prado::createComponent($this->getTransactionClass(), $this);
346 346
 		}
347 347
 		else
348 348
 			throw new TDbException('dbconnection_connection_inactive');
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 	 */
365 365
 	public function setTransactionClass($value)
366 366
 	{
367
-		$this->_transactionClass = (string)$value;
367
+		$this->_transactionClass = (string) $value;
368 368
 	}
369 369
 
370 370
 	/**
@@ -373,9 +373,9 @@  discard block
 block discarded – undo
373 373
 	 * @return string the row ID of the last row inserted, or the last value retrieved from the sequence object
374 374
 	 * @see http://www.php.net/manual/en/function.PDO-lastInsertId.php
375 375
 	 */
376
-	public function getLastInsertID($sequenceName='')
376
+	public function getLastInsertID($sequenceName = '')
377 377
 	{
378
-		if($this->getActive())
378
+		if ($this->getActive())
379 379
 			return $this->_pdo->lastInsertId($sequenceName);
380 380
 		else
381 381
 			throw new TDbException('dbconnection_connection_inactive');
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 	 */
390 390
 	public function quoteString($str)
391 391
 	{
392
-		if($this->getActive())
392
+		if ($this->getActive())
393 393
 			return $this->_pdo->quote($str);
394 394
 		else
395 395
 			throw new TDbException('dbconnection_connection_inactive');
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 	 */
431 431
 	public function getDbMetaData()
432 432
 	{
433
-		if($this->_dbMeta===null)
433
+		if ($this->_dbMeta === null)
434 434
 		{
435 435
 			Prado::using('System.Data.Common.TDbMetaData');
436 436
 			$this->_dbMeta = TDbMetaData::getInstance($this);
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 	 */
444 444
 	public function getColumnCase()
445 445
 	{
446
-		switch($this->getAttribute(PDO::ATTR_CASE))
446
+		switch ($this->getAttribute(PDO::ATTR_CASE))
447 447
 		{
448 448
 			case PDO::CASE_NATURAL:
449 449
 				return TDbColumnCaseMode::Preserved;
@@ -459,19 +459,19 @@  discard block
 block discarded – undo
459 459
 	 */
460 460
 	public function setColumnCase($value)
461 461
 	{
462
-		switch(TPropertyValue::ensureEnum($value,'TDbColumnCaseMode'))
462
+		switch (TPropertyValue::ensureEnum($value, 'TDbColumnCaseMode'))
463 463
 		{
464 464
 			case TDbColumnCaseMode::Preserved:
465
-				$value=PDO::CASE_NATURAL;
465
+				$value = PDO::CASE_NATURAL;
466 466
 				break;
467 467
 			case TDbColumnCaseMode::LowerCase:
468
-				$value=PDO::CASE_LOWER;
468
+				$value = PDO::CASE_LOWER;
469 469
 				break;
470 470
 			case TDbColumnCaseMode::UpperCase:
471
-				$value=PDO::CASE_UPPER;
471
+				$value = PDO::CASE_UPPER;
472 472
 				break;
473 473
 		}
474
-		$this->setAttribute(PDO::ATTR_CASE,$value);
474
+		$this->setAttribute(PDO::ATTR_CASE, $value);
475 475
 	}
476 476
 
477 477
 	/**
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 	 */
480 480
 	public function getNullConversion()
481 481
 	{
482
-		switch($this->getAttribute(PDO::ATTR_ORACLE_NULLS))
482
+		switch ($this->getAttribute(PDO::ATTR_ORACLE_NULLS))
483 483
 		{
484 484
 			case PDO::NULL_NATURAL:
485 485
 				return TDbNullConversionMode::Preserved;
@@ -495,19 +495,19 @@  discard block
 block discarded – undo
495 495
 	 */
496 496
 	public function setNullConversion($value)
497 497
 	{
498
-		switch(TPropertyValue::ensureEnum($value,'TDbNullConversionMode'))
498
+		switch (TPropertyValue::ensureEnum($value, 'TDbNullConversionMode'))
499 499
 		{
500 500
 			case TDbNullConversionMode::Preserved:
501
-				$value=PDO::NULL_NATURAL;
501
+				$value = PDO::NULL_NATURAL;
502 502
 				break;
503 503
 			case TDbNullConversionMode::EmptyStringToNull:
504
-				$value=PDO::NULL_EMPTY_STRING;
504
+				$value = PDO::NULL_EMPTY_STRING;
505 505
 				break;
506 506
 			case TDbNullConversionMode::NullToEmptyString:
507
-				$value=PDO::NULL_TO_STRING;
507
+				$value = PDO::NULL_TO_STRING;
508 508
 				break;
509 509
 		}
510
-		$this->setAttribute(PDO::ATTR_ORACLE_NULLS,$value);
510
+		$this->setAttribute(PDO::ATTR_ORACLE_NULLS, $value);
511 511
 	}
512 512
 
513 513
 	/**
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 	 */
526 526
 	public function setAutoCommit($value)
527 527
 	{
528
-		$this->setAttribute(PDO::ATTR_AUTOCOMMIT,TPropertyValue::ensureBoolean($value));
528
+		$this->setAttribute(PDO::ATTR_AUTOCOMMIT, TPropertyValue::ensureBoolean($value));
529 529
 	}
530 530
 
531 531
 	/**
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 	 */
544 544
 	public function setPersistent($value)
545 545
 	{
546
-		return $this->setAttribute(PDO::ATTR_PERSISTENT,TPropertyValue::ensureBoolean($value));
546
+		return $this->setAttribute(PDO::ATTR_PERSISTENT, TPropertyValue::ensureBoolean($value));
547 547
 	}
548 548
 
549 549
 	/**
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 	 */
612 612
 	public function getAttribute($name)
613 613
 	{
614
-		if($this->getActive())
614
+		if ($this->getActive())
615 615
 			return $this->_pdo->getAttribute($name);
616 616
 		else
617 617
 			throw new TDbException('dbconnection_connection_inactive');
@@ -623,12 +623,12 @@  discard block
 block discarded – undo
623 623
 	 * @param mixed the attribute value
624 624
 	 * @see http://www.php.net/manual/en/function.PDO-setAttribute.php
625 625
 	 */
626
-	public function setAttribute($name,$value)
626
+	public function setAttribute($name, $value)
627 627
 	{
628
-		if($this->_pdo instanceof PDO)
629
-			$this->_pdo->setAttribute($name,$value);
628
+		if ($this->_pdo instanceof PDO)
629
+			$this->_pdo->setAttribute($name, $value);
630 630
 		else
631
-			$this->_attributes[$name]=$value;
631
+			$this->_attributes[$name] = $value;
632 632
 	}
633 633
 }
634 634
 
@@ -644,15 +644,15 @@  discard block
 block discarded – undo
644 644
 	/**
645 645
 	 * Column name cases are kept as is from the database
646 646
 	 */
647
-	const Preserved='Preserved';
647
+	const Preserved = 'Preserved';
648 648
 	/**
649 649
 	 * Column names are converted to lower case
650 650
 	 */
651
-	const LowerCase='LowerCase';
651
+	const LowerCase = 'LowerCase';
652 652
 	/**
653 653
 	 * Column names are converted to upper case
654 654
 	 */
655
-	const UpperCase='UpperCase';
655
+	const UpperCase = 'UpperCase';
656 656
 }
657 657
 
658 658
 /**
@@ -667,14 +667,14 @@  discard block
 block discarded – undo
667 667
 	/**
668 668
 	 * No conversion is performed for null and empty values.
669 669
 	 */
670
-	const Preserved='Preserved';
670
+	const Preserved = 'Preserved';
671 671
 	/**
672 672
 	 * NULL is converted to empty string
673 673
 	 */
674
-	const NullToEmptyString='NullToEmptyString';
674
+	const NullToEmptyString = 'NullToEmptyString';
675 675
 	/**
676 676
 	 * Empty string is converted to NULL
677 677
 	 */
678
-	const EmptyStringToNull='EmptyStringToNull';
678
+	const EmptyStringToNull = 'EmptyStringToNull';
679 679
 }
680 680
 
Please login to merge, or discard this patch.
Braces   +39 added lines, -32 removed lines patch added patch discarded remove patch
@@ -164,10 +164,11 @@  discard block
 block discarded – undo
164 164
 		$value=TPropertyValue::ensureBoolean($value);
165 165
 		if($value!==$this->_active)
166 166
 		{
167
-			if($value)
168
-				$this->open();
169
-			else
170
-				$this->close();
167
+			if($value) {
168
+							$this->open();
169
+			} else {
170
+							$this->close();
171
+			}
171 172
 		}
172 173
 	}
173 174
 
@@ -189,8 +190,7 @@  discard block
 block discarded – undo
189 190
 				$this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
190 191
 				$this->_active=true;
191 192
 				$this->setConnectionCharset();
192
-			}
193
-			catch(PDOException $e)
193
+			} catch(PDOException $e)
194 194
 			{
195 195
 				throw new TDbException('dbconnection_open_failed',$e->getMessage());
196 196
 			}
@@ -214,8 +214,9 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	protected function setConnectionCharset()
216 216
 	{
217
-		if ($this->_charset === '' || $this->_active === false)
218
-			return;
217
+		if ($this->_charset === '' || $this->_active === false) {
218
+					return;
219
+		}
219 220
 		switch ($this->_pdo->getAttribute(PDO::ATTR_DRIVER_NAME))
220 221
 		{
221 222
 			case 'mysql':
@@ -313,10 +314,11 @@  discard block
 block discarded – undo
313 314
 	 */
314 315
 	public function createCommand($sql)
315 316
 	{
316
-		if($this->getActive())
317
-			return new TDbCommand($this,$sql);
318
-		else
319
-			throw new TDbException('dbconnection_connection_inactive');
317
+		if($this->getActive()) {
318
+					return new TDbCommand($this,$sql);
319
+		} else {
320
+					throw new TDbException('dbconnection_connection_inactive');
321
+		}
320 322
 	}
321 323
 
322 324
 	/**
@@ -326,8 +328,9 @@  discard block
 block discarded – undo
326 328
 	{
327 329
 		if($this->_transaction!==null)
328 330
 		{
329
-			if($this->_transaction->getActive())
330
-				return $this->_transaction;
331
+			if($this->_transaction->getActive()) {
332
+							return $this->_transaction;
333
+			}
331 334
 		}
332 335
 		return null;
333 336
 	}
@@ -343,9 +346,9 @@  discard block
 block discarded – undo
343 346
 		{
344 347
 			$this->_pdo->beginTransaction();
345 348
 			return $this->_transaction=Prado::createComponent($this->getTransactionClass(), $this);
349
+		} else {
350
+					throw new TDbException('dbconnection_connection_inactive');
346 351
 		}
347
-		else
348
-			throw new TDbException('dbconnection_connection_inactive');
349 352
 	}
350 353
 
351 354
 	/**
@@ -375,10 +378,11 @@  discard block
 block discarded – undo
375 378
 	 */
376 379
 	public function getLastInsertID($sequenceName='')
377 380
 	{
378
-		if($this->getActive())
379
-			return $this->_pdo->lastInsertId($sequenceName);
380
-		else
381
-			throw new TDbException('dbconnection_connection_inactive');
381
+		if($this->getActive()) {
382
+					return $this->_pdo->lastInsertId($sequenceName);
383
+		} else {
384
+					throw new TDbException('dbconnection_connection_inactive');
385
+		}
382 386
 	}
383 387
 
384 388
 	/**
@@ -389,10 +393,11 @@  discard block
 block discarded – undo
389 393
 	 */
390 394
 	public function quoteString($str)
391 395
 	{
392
-		if($this->getActive())
393
-			return $this->_pdo->quote($str);
394
-		else
395
-			throw new TDbException('dbconnection_connection_inactive');
396
+		if($this->getActive()) {
397
+					return $this->_pdo->quote($str);
398
+		} else {
399
+					throw new TDbException('dbconnection_connection_inactive');
400
+		}
396 401
 	}
397 402
 
398 403
 	/**
@@ -611,10 +616,11 @@  discard block
 block discarded – undo
611 616
 	 */
612 617
 	public function getAttribute($name)
613 618
 	{
614
-		if($this->getActive())
615
-			return $this->_pdo->getAttribute($name);
616
-		else
617
-			throw new TDbException('dbconnection_connection_inactive');
619
+		if($this->getActive()) {
620
+					return $this->_pdo->getAttribute($name);
621
+		} else {
622
+					throw new TDbException('dbconnection_connection_inactive');
623
+		}
618 624
 	}
619 625
 
620 626
 	/**
@@ -625,10 +631,11 @@  discard block
 block discarded – undo
625 631
 	 */
626 632
 	public function setAttribute($name,$value)
627 633
 	{
628
-		if($this->_pdo instanceof PDO)
629
-			$this->_pdo->setAttribute($name,$value);
630
-		else
631
-			$this->_attributes[$name]=$value;
634
+		if($this->_pdo instanceof PDO) {
635
+					$this->_pdo->setAttribute($name,$value);
636
+		} else {
637
+					$this->_attributes[$name]=$value;
638
+		}
632 639
 	}
633 640
 }
634 641
 
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TDbConnection class file
4
- *
5
- * @author Qiang Xue <[email protected]>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Data
10
- */
3
+	 * TDbConnection class file
4
+	 *
5
+	 * @author Qiang Xue <[email protected]>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
+	 * @package System.Data
10
+	 */
11 11
 
12 12
 Prado::using('System.Data.TDbTransaction');
13 13
 Prado::using('System.Data.TDbCommand');
Please login to merge, or discard this patch.
framework/Data/TDbDataReader.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -58,6 +58,7 @@  discard block
 block discarded – undo
58 58
 	 * should match the case of the column, as returned by the driver.
59 59
 	 * @param mixed Name of the PHP variable to which the column will be bound.
60 60
 	 * @param int Data type of the parameter
61
+	 * @param integer $column
61 62
 	 * @see http://www.php.net/manual/en/function.PDOStatement-bindColumn.php
62 63
 	 */
63 64
 	public function bindColumn($column, &$value, $dataType=null)
@@ -89,6 +90,7 @@  discard block
 block discarded – undo
89 90
 	/**
90 91
 	 * Returns a single column from the next row of a result set.
91 92
 	 * @param int zero-based column index
93
+	 * @param integer $columnIndex
92 94
 	 * @return mixed|false the column of the current row, false if no more row available
93 95
 	 */
94 96
 	public function readColumn($columnIndex)
@@ -100,6 +102,8 @@  discard block
 block discarded – undo
100 102
 	 * Returns a single column from the next row of a result set.
101 103
 	 * @param string class name of the object to be created and populated
102 104
 	 * @param array list of column names whose values are to be passed as parameters in the constructor of the class being created
105
+	 * @param string $className
106
+	 * @param string[] $fields
103 107
 	 * @return mixed|false the populated object, false if no more row of data available
104 108
 	 */
105 109
 	public function readObject($className,$fields)
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 class TDbDataReader extends TComponent implements Iterator
36 36
 {
37 37
 	private $_statement;
38
-	private $_closed=false;
38
+	private $_closed = false;
39 39
 	private $_row;
40
-	private $_index=-1;
40
+	private $_index = -1;
41 41
 
42 42
 	/**
43 43
 	 * Constructor.
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 */
46 46
 	public function __construct(TDbCommand $command)
47 47
 	{
48
-		$this->_statement=$command->getPdoStatement();
48
+		$this->_statement = $command->getPdoStatement();
49 49
 		$this->_statement->setFetchMode(PDO::FETCH_ASSOC);
50 50
 	}
51 51
 
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
 	 * @param int Data type of the parameter
61 61
 	 * @see http://www.php.net/manual/en/function.PDOStatement-bindColumn.php
62 62
 	 */
63
-	public function bindColumn($column, &$value, $dataType=null)
63
+	public function bindColumn($column, &$value, $dataType = null)
64 64
 	{
65
-		if($dataType===null)
66
-			$this->_statement->bindColumn($column,$value);
65
+		if ($dataType === null)
66
+			$this->_statement->bindColumn($column, $value);
67 67
 		else
68
-			$this->_statement->bindColumn($column,$value,$dataType);
68
+			$this->_statement->bindColumn($column, $value, $dataType);
69 69
 	}
70 70
 
71 71
 	/**
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	public function setFetchMode($mode)
75 75
 	{
76
-		$params=func_get_args();
77
-		call_user_func_array(array($this->_statement,'setFetchMode'),$params);
76
+		$params = func_get_args();
77
+		call_user_func_array(array($this->_statement, 'setFetchMode'), $params);
78 78
 	}
79 79
 
80 80
 	/**
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
 	 * @param array list of column names whose values are to be passed as parameters in the constructor of the class being created
103 103
 	 * @return mixed|false the populated object, false if no more row of data available
104 104
 	 */
105
-	public function readObject($className,$fields)
105
+	public function readObject($className, $fields)
106 106
 	{
107
-		return $this->_statement->fetchObject($className,$fields);
107
+		return $this->_statement->fetchObject($className, $fields);
108 108
 	}
109 109
 
110 110
 	/**
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	public function close()
135 135
 	{
136 136
 		$this->_statement->closeCursor();
137
-		$this->_closed=true;
137
+		$this->_closed = true;
138 138
 	}
139 139
 
140 140
 	/**
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
 	 */
172 172
 	public function rewind()
173 173
 	{
174
-		if($this->_index<0)
174
+		if ($this->_index < 0)
175 175
 		{
176
-			$this->_row=$this->_statement->fetch();
177
-			$this->_index=0;
176
+			$this->_row = $this->_statement->fetch();
177
+			$this->_index = 0;
178 178
 		}
179 179
 		else
180 180
 			throw new TDbException('dbdatareader_rewind_invalid');
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	public function next()
208 208
 	{
209
-		$this->_row=$this->_statement->fetch();
209
+		$this->_row = $this->_statement->fetch();
210 210
 		$this->_index++;
211 211
 	}
212 212
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	 */
218 218
 	public function valid()
219 219
 	{
220
-		return $this->_row!==false;
220
+		return $this->_row !== false;
221 221
 	}
222 222
 }
223 223
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -62,10 +62,11 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function bindColumn($column, &$value, $dataType=null)
64 64
 	{
65
-		if($dataType===null)
66
-			$this->_statement->bindColumn($column,$value);
67
-		else
68
-			$this->_statement->bindColumn($column,$value,$dataType);
65
+		if($dataType===null) {
66
+					$this->_statement->bindColumn($column,$value);
67
+		} else {
68
+					$this->_statement->bindColumn($column,$value,$dataType);
69
+		}
69 70
 	}
70 71
 
71 72
 	/**
@@ -175,9 +176,9 @@  discard block
 block discarded – undo
175 176
 		{
176 177
 			$this->_row=$this->_statement->fetch();
177 178
 			$this->_index=0;
179
+		} else {
180
+					throw new TDbException('dbdatareader_rewind_invalid');
178 181
 		}
179
-		else
180
-			throw new TDbException('dbdatareader_rewind_invalid');
181 182
 	}
182 183
 
183 184
 	/**
Please login to merge, or discard this patch.