Test Failed
Push — 3.4 ( 14426e...6a587e )
by Nicolas
07:50
created
src/Mouf/Database/TDBM/TDBMService.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	private $tableToBeanMap = [];
149 149
 	
150 150
 	public function __construct() {
151
-		register_shutdown_function(array($this,"completeSaveOnExit"));
151
+		register_shutdown_function(array($this, "completeSaveOnExit"));
152 152
 		if (extension_loaded('weakref')) {
153 153
 			$this->objectStorage = new WeakrefObjectStorage();
154 154
 		} else {
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 				$objects = $this->getObjects($table_name, $filters, null, null, null, $className);
369 369
 				if (count($objects) == 0) {
370 370
 					return null;
371
-				} elseif (count($objects) > 1) {
371
+				} elseif (count($objects)>1) {
372 372
 					throw new DuplicateRowException("Error while querying an object for table '$table_name': ".count($objects)." rows have been returned, but we should have received at most one.");
373 373
 				}
374 374
 				// Return the first and only object.
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 	 * @param string $className Optional: The name of the class to instanciate. This class must extend the TDBMObject class. If none is specified, a TDBMObject instance will be returned.
446 446
 	 * @return TDBMObject
447 447
 	 */
448
-	public function getNewObject($table_name, $auto_assign_id=true, $className = null) {
448
+	public function getNewObject($table_name, $auto_assign_id = true, $className = null) {
449 449
 		if ($this->dbConnection == null) {
450 450
 			throw new TDBMException("Error while calling TDBMObject::getNewObject(): No connection has been established on the database!");
451 451
 		}
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 		$object = new $className($this, $table_name);
480 480
 
481 481
 		if ($auto_assign_id && !$this->isPrimaryKeyAutoIncrement($table_name)) {
482
-			$pk_table =  $this->getPrimaryKeyStatic($table_name);
483
-			if (count($pk_table)==1)
482
+			$pk_table = $this->getPrimaryKeyStatic($table_name);
483
+			if (count($pk_table) == 1)
484 484
 			{
485 485
 				$root_table = $this->dbConnection->findRootSequenceTable($table_name);
486 486
 				$id = $this->dbConnection->nextId($root_table);
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 					$sql = "SELECT MAX(".$this->dbConnection->escapeDBItem($pk_table[0]).") AS maxkey FROM ".$root_table;
491 491
 					$res = $this->dbConnection->getAll($sql);
492 492
 					// NOTE: this will work only if the ID is an integer!
493
-					$newid = $res[0]['maxkey'] + 1;
493
+					$newid = $res[0]['maxkey']+1;
494 494
 					if ($newid>$id) {
495 495
 						$id = $newid;
496 496
 					}
@@ -520,17 +520,17 @@  discard block
 block discarded – undo
520 520
 			// Now for the object_id
521 521
 			$object_id = $object->TDBMObject_id;
522 522
 			// If there is only one primary key:
523
-			if (count($pk_table)==1) {
523
+			if (count($pk_table) == 1) {
524 524
 				$sql_where = $this->dbConnection->escapeDBItem($pk_table[0])."=".$this->dbConnection->quoteSmart($object->TDBMObject_id);
525 525
 			} else {
526 526
 				$ids = unserialize($object_id);
527
-				$i=0;
527
+				$i = 0;
528 528
 				$sql_where_array = array();
529 529
 				foreach ($pk_table as $pk) {
530 530
 					$sql_where_array[] = $this->dbConnection->escapeDBItem($pk)."=".$this->dbConnection->quoteSmart($ids[$i]);
531 531
 					$i++;
532 532
 				}
533
-				$sql_where = implode(" AND ",$sql_where_array);
533
+				$sql_where = implode(" AND ", $sql_where_array);
534 534
 			}
535 535
 
536 536
 
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 	 * @param string $className Optional: The name of the class to instanciate. This class must extend the TDBMObject class. If none is specified, a TDBMObject instance will be returned.
614 614
 	 * @return array|\Generator|TDBMObjectArray The result set of the query as a TDBMObjectArray (an array of TDBMObjects with special properties)
615 615
 	 */
616
-	public function getObjectsFromSQL($table_name, $sql, $from=null, $limit=null, $className=null) {
616
+	public function getObjectsFromSQL($table_name, $sql, $from = null, $limit = null, $className = null) {
617 617
 		if ($this->dbConnection == null) {
618 618
 			throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!");
619 619
 		}
@@ -656,10 +656,10 @@  discard block
 block discarded – undo
656 656
 					$firstLine = false;
657 657
 				}
658 658
 				foreach ($fullCaseRow as $key=>$value) {
659
-					$row[$keysStandardCased[$key]]=$value;
659
+					$row[$keysStandardCased[$key]] = $value;
660 660
 				}
661 661
 				$pk_table = $this->primary_keys[$table_name];
662
-				if (count($pk_table)==1)
662
+				if (count($pk_table) == 1)
663 663
 				{
664 664
 					if (!isset($keysStandardCased[$pk_table[0]])) {
665 665
 						throw new TDBMException("Bad SQL request passed to getObjectsFromSQL. The SQL request should return all the rows from the '$table_name' table. Could not find primary key in this set of rows. SQL request passed: ".$sql);
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 					$id = serialize($ids);
677 677
 				}
678 678
 
679
-                $obj = $this->objectStorage->get($table_name,$id);
679
+                $obj = $this->objectStorage->get($table_name, $id);
680 680
 				if ($obj === null)
681 681
 				{
682 682
 					if (!is_a($className, "Mouf\\Database\\TDBM\\TDBMObject", true)) {
@@ -731,10 +731,10 @@  discard block
 block discarded – undo
731 731
 				$firstLine = false;
732 732
 			}
733 733
 			foreach ($fullCaseRow as $key=>$value) {
734
-				$row[$keysStandardCased[$key]]=$value;
734
+				$row[$keysStandardCased[$key]] = $value;
735 735
 			}
736 736
 			$pk_table = $this->primary_keys[$table_name];
737
-			if (count($pk_table)==1)
737
+			if (count($pk_table) == 1)
738 738
 			{
739 739
 				if (!isset($keysStandardCased[$pk_table[0]])) {
740 740
 					throw new TDBMException("Bad SQL request passed to getObjectsFromSQL. The SQL request should return all the rows from the '$table_name' table. Could not find primary key in this set of rows. SQL request passed: ".$sql);
@@ -829,14 +829,14 @@  discard block
 block discarded – undo
829 829
 		// Now, let's commit or rollback if needed.
830 830
 		if ($this->dbConnection != null && $this->dbConnection->hasActiveTransaction()) {
831 831
 			if ($this->commitOnQuit) {
832
-				try  {
832
+				try {
833 833
 					$this->dbConnection->commit();
834 834
 				} catch (Exception $e) {
835 835
 					echo $e->getMessage()."<br/>";
836 836
 					echo $e->getTraceAsString();
837 837
 				}
838 838
 			} else {
839
-				try  {
839
+				try {
840 840
 					$this->dbConnection->rollback();
841 841
 				} catch (Exception $e) {
842 842
 					echo $e->getMessage()."<br/>";
@@ -897,21 +897,21 @@  discard block
 block discarded – undo
897 897
 	 * @param string $sql
898 898
 	 * @return array the result of your query
899 899
 	 */
900
-	public function getTransientObjectsFromSQL($sql,$classname=null) {
900
+	public function getTransientObjectsFromSQL($sql, $classname = null) {
901 901
 		if ($this->dbConnection == null) {
902 902
 			throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!");
903 903
 		}
904
-		return $this->dbConnection->getAll($sql, \PDO::FETCH_CLASS,$classname);
904
+		return $this->dbConnection->getAll($sql, \PDO::FETCH_CLASS, $classname);
905 905
 	}
906 906
 
907 907
 
908 908
 	private function to_explain_string($path) {
909 909
 		$msg = '';
910 910
 		foreach ($path as $constraint) {
911
-			if ($constraint['type']=='1*') {
911
+			if ($constraint['type'] == '1*') {
912 912
 				$msg .= 'Table "'.$constraint['table1'].'" points to "'.$constraint['table2'].'" through its foreign key "'.$constraint['col1'].'"\n';
913 913
 			}
914
-			elseif ($constraint['type']=='*1') {
914
+			elseif ($constraint['type'] == '*1') {
915 915
 				$msg .= 'Table "'.$constraint['table1'].'" is pointed by "'.$constraint['table2'].'" through its foreign key "'.$constraint['col2'].'"\n';
916 916
 			}
917 917
 		}
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 		$this->loadCache();
931 931
 
932 932
 		$path = array();
933
-		$queue = array(array($table,array()));
933
+		$queue = array(array($table, array()));
934 934
 
935 935
 		$found = false;
936 936
 		$found_depth = 0;
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
 				{
966 966
 					break;
967 967
 				}
968
-				if ($ret==true)
968
+				if ($ret == true)
969 969
 				{
970 970
 					// Ok, we got one, we will continue a bit more until we reach the next level in the tree,
971 971
 					// just to see if there is no ambiguity
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
 				}
976 976
 
977 977
 				// At each iteration, let's check the time.
978
-				if ($this->trackExecutionTime && microtime(true)-self::$script_start_up_time > $max_execution_time && $max_execution_time!=0) {
978
+				if ($this->trackExecutionTime && microtime(true)-self::$script_start_up_time>$max_execution_time && $max_execution_time != 0) {
979 979
 					// Call check table names
980 980
 					$this->checkTablesExist($tables);
981 981
 
@@ -986,11 +986,11 @@  discard block
 block discarded – undo
986 986
 			}
987 987
 		}
988 988
 
989
-		$ambiguity =false;
989
+		$ambiguity = false;
990 990
 		$msg = '';
991 991
 		foreach ($tables_paths as $table_path) {
992 992
 			// If any table has not been found, throw an exception
993
-			if (!isset($table_path['founddepth']) || $table_path['founddepth']==null) {
993
+			if (!isset($table_path['founddepth']) || $table_path['founddepth'] == null) {
994 994
 				// First, check if the tables do exist.
995 995
 				$this->checkTablesExist(array($table, $table_path['name']));
996 996
 				// Else, throw an error.
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
 						'table2' => $depArr['table1'],
1053 1053
 						'col1' => $depArr['col2'],
1054 1054
 						'col2' => $depArr['col1'],
1055
-						'type' => (($depArr['type'] == '1*')?'*1':'1*')
1055
+						'type' => (($depArr['type'] == '1*') ? '*1' : '1*')
1056 1056
 				);
1057 1057
 			}, $toRevertPath);
1058 1058
 			return array_reverse($invertedDependencies);
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
 	 * @param unknown_type $paths
1071 1071
 	 */
1072 1072
 	private function flatten_paths($paths) {
1073
-		$flat_path=array();
1073
+		$flat_path = array();
1074 1074
 		foreach ($paths as $path_bigarray) {
1075 1075
 			$path = $path_bigarray['paths'][0];
1076 1076
 
@@ -1109,9 +1109,9 @@  discard block
 block discarded – undo
1109 1109
 		$path = $current_vars[1];
1110 1110
 
1111 1111
 		foreach ($target_tables as $id=>$target_table) {
1112
-			if ($target_table['name'] == $current_table && (!isset($target_table['founddepth']) || $target_table['founddepth']==null || $target_table['founddepth']==count($path))) {
1112
+			if ($target_table['name'] == $current_table && (!isset($target_table['founddepth']) || $target_table['founddepth'] == null || $target_table['founddepth'] == count($path))) {
1113 1113
 				// When a path is found to a table, we mark the table as found with its depth.
1114
-				$target_tables[$id]['founddepth']=count($path);
1114
+				$target_tables[$id]['founddepth'] = count($path);
1115 1115
 
1116 1116
 				// Then we add the path to table to the target_tables array
1117 1117
 				$target_tables[$id]['paths'][] = $path;
@@ -1142,12 +1142,12 @@  discard block
 block discarded – undo
1142 1142
 			$already_done = false;
1143 1143
 			foreach ($path as $previous_constraint)
1144 1144
 			{
1145
-				if ($previous_constraint['type']=='1*' && $current_table == $previous_constraint["table2"] && $col2 == $previous_constraint["col2"] && $table1 == $previous_constraint["table1"] && $col1 == $previous_constraint["col1"])
1145
+				if ($previous_constraint['type'] == '1*' && $current_table == $previous_constraint["table2"] && $col2 == $previous_constraint["col2"] && $table1 == $previous_constraint["table1"] && $col1 == $previous_constraint["col1"])
1146 1146
 				{
1147 1147
 					$already_done = true;
1148 1148
 					break;
1149 1149
 				}
1150
-				elseif ($previous_constraint['type']=='*1' && $current_table == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"] && $table1 == $previous_constraint["table2"] && $col1 == $previous_constraint["col2"])
1150
+				elseif ($previous_constraint['type'] == '*1' && $current_table == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"] && $table1 == $previous_constraint["table2"] && $col1 == $previous_constraint["col2"])
1151 1151
 				{
1152 1152
 					$already_done = true;
1153 1153
 					break;
@@ -1175,12 +1175,12 @@  discard block
 block discarded – undo
1175 1175
 			$already_done = false;
1176 1176
 			foreach ($path as $previous_constraint)
1177 1177
 			{
1178
-				if ($previous_constraint['type']=='1*' && $table2 == $previous_constraint["table2"] && $col2 == $previous_constraint["col2"])
1178
+				if ($previous_constraint['type'] == '1*' && $table2 == $previous_constraint["table2"] && $col2 == $previous_constraint["col2"])
1179 1179
 				{
1180 1180
 					$already_done = true;
1181 1181
 					break;
1182 1182
 				}
1183
-				elseif ($previous_constraint['type']=='*1' && $table2 == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"])
1183
+				elseif ($previous_constraint['type'] == '*1' && $table2 == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"])
1184 1184
 				{
1185 1185
 					$already_done = true;
1186 1186
 					break;
@@ -1289,7 +1289,7 @@  discard block
 block discarded – undo
1289 1289
 	 * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null).
1290 1290
 	 * @return TDBMObjectArray A TDBMObjectArray containing the resulting objects of the query.
1291 1291
 	 */
1292
-	public function getObjects($table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $className=null, $hint_path=null) {
1292
+	public function getObjects($table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $className = null, $hint_path = null) {
1293 1293
 		if ($this->dbConnection == null) {
1294 1294
 			throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!");
1295 1295
 		}
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
 	 * @param unknown_type $hint_path
1306 1306
 	 * @return integer
1307 1307
 	 */
1308
-	public function getCount($table_name, $filter_bag=null, $hint_path=null) {
1308
+	public function getCount($table_name, $filter_bag = null, $hint_path = null) {
1309 1309
 		if ($this->dbConnection == null) {
1310 1310
 			throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!");
1311 1311
 		}
@@ -1323,7 +1323,7 @@  discard block
 block discarded – undo
1323 1323
 	 * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null).
1324 1324
 	 * @return string The SQL that would be executed.
1325 1325
 	 */
1326
-	public function explainSQLGetObjects($table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $hint_path=null) 	{
1326
+	public function explainSQLGetObjects($table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $hint_path = null) {
1327 1327
 		if ($this->dbConnection == null) {
1328 1328
 			throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!");
1329 1329
 		}
@@ -1341,7 +1341,7 @@  discard block
 block discarded – undo
1341 1341
 	 * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null).
1342 1342
 	 * @return string The SQL that would be executed.
1343 1343
 	 */
1344
-	public function explainRequestAsTextGetObjects($table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $hint_path=null) 	{
1344
+	public function explainRequestAsTextGetObjects($table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $hint_path = null) {
1345 1345
 		if ($this->dbConnection == null) {
1346 1346
 			throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!");
1347 1347
 		}
@@ -1362,12 +1362,12 @@  discard block
 block discarded – undo
1362 1362
 	 * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null).
1363 1363
 	 * @return string The SQL that would be executed.
1364 1364
 	 */
1365
-	public function explainRequestAsHTMLGetObjects($table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $hint_path=null, $x=10, $y=10) 	{
1365
+	public function explainRequestAsHTMLGetObjects($table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $hint_path = null, $x = 10, $y = 10) {
1366 1366
 		if ($this->dbConnection == null) {
1367 1367
 			throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!");
1368 1368
 		}
1369 1369
 		$tree = $this->getObjectsByMode('explainTree', $table_name, $filter_bag, $orderby_bag, $from, $limit, $hint_path);
1370
-		return $this->drawTree($tree,$x,$y);
1370
+		return $this->drawTree($tree, $x, $y);
1371 1371
 	}
1372 1372
 
1373 1373
 	/**
@@ -1384,7 +1384,7 @@  discard block
 block discarded – undo
1384 1384
 	 * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null).
1385 1385
 	 * @return array|\Generator|TDBMObjectArray|int An array or object containing the resulting objects of the query.
1386 1386
 	 */
1387
-	public function getObjectsByMode($mode, $table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $className=null, $hint_path=null) {
1387
+	public function getObjectsByMode($mode, $table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $className = null, $hint_path = null) {
1388 1388
 		$this->completeSave();
1389 1389
 		$this->loadCache();
1390 1390
 
@@ -1423,7 +1423,7 @@  discard block
 block discarded – undo
1423 1423
 			}
1424 1424
 		}
1425 1425
 
1426
-		if (count($needed_table_array)==0)
1426
+		if (count($needed_table_array) == 0)
1427 1427
 		{
1428 1428
 			$sql = $this->dbConnection->escapeDBItem($table_name); //Make by Pierre PIV (add escapeDBItem)
1429 1429
 
@@ -1431,14 +1431,14 @@  discard block
 block discarded – undo
1431 1431
 			throw new TDBMException("TODO: explainTree not implemented for only one table.");
1432 1432
 		}
1433 1433
 		else {
1434
-			if ($hint_path!=null && $mode != 'explainTree')
1434
+			if ($hint_path != null && $mode != 'explainTree')
1435 1435
 			{
1436 1436
 				$path = $hint_path;
1437 1437
 				$flat_path = $this->flatten_paths($path);
1438 1438
 			}
1439 1439
 			else
1440 1440
 			{
1441
-				$full_paths = $this->static_find_paths($table_name,$needed_table_array);
1441
+				$full_paths = $this->static_find_paths($table_name, $needed_table_array);
1442 1442
 
1443 1443
 				if ($mode == 'explainTree') {
1444 1444
 					return $this->getTablePathsTree($full_paths);
@@ -1481,7 +1481,7 @@  discard block
 block discarded – undo
1481 1481
 			*/
1482 1482
 			$is_ok = true;
1483 1483
 			foreach ($path as $step) {
1484
-				if ($step["type"]=="1*") {
1484
+				if ($step["type"] == "1*") {
1485 1485
 					$is_ok = false;
1486 1486
 					break;
1487 1487
 				}
@@ -1506,7 +1506,7 @@  discard block
 block discarded – undo
1506 1506
 				$orderby_columns_array = array_merge($orderby_columns_array, $orderby_object->toSqlStatementsArray());
1507 1507
 			}
1508 1508
 
1509
-			$orderby_statement = ' ORDER BY '.implode(',',$orderby_columns_array);
1509
+			$orderby_statement = ' ORDER BY '.implode(',', $orderby_columns_array);
1510 1510
 			$count = 0;
1511 1511
 			foreach ($orderby_columns_array as $id=>$orderby_statement_phrase) {
1512 1512
 				// Let's remove the trailing ASC or DESC and add AS tdbm_reserved_col_Xxx
@@ -1524,10 +1524,10 @@  discard block
 block discarded – undo
1524 1524
 				$orderby_columns_array[$id] = $orderby_statement_phrase.' AS tdbm_reserved_col_'.$count;
1525 1525
 				$count++;
1526 1526
 			}
1527
-			$orderby_column_statement = ', '.implode(',',$orderby_columns_array);
1527
+			$orderby_column_statement = ', '.implode(',', $orderby_columns_array);
1528 1528
 		}
1529 1529
 
1530
-		if ($mode=="getCount") {
1530
+		if ($mode == "getCount") {
1531 1531
 			// Let's get the list of primary keys to perform a DISTINCT request.
1532 1532
 			$pk_table = $this->getPrimaryKeyStatic($table_name);
1533 1533
 				
@@ -1561,7 +1561,7 @@  discard block
 block discarded – undo
1561 1561
 		if ($mode == 'explainSQL') {
1562 1562
 			return $sql;
1563 1563
 		}
1564
-		return $this->getObjectsFromSQL($table_name, $sql,  $from, $limit, $className);
1564
+		return $this->getObjectsFromSQL($table_name, $sql, $from, $limit, $className);
1565 1565
 
1566 1566
 	}
1567 1567
 
@@ -1586,17 +1586,17 @@  discard block
 block discarded – undo
1586 1586
 		// Second, let's take all the objects out of the filter bag, and let's make filters from them
1587 1587
 		$filter_bag2 = array();
1588 1588
 		foreach ($filter_bag as $thing) {
1589
-			if (is_a($thing,'Mouf\\Database\\TDBM\\Filters\\FilterInterface')) {
1589
+			if (is_a($thing, 'Mouf\\Database\\TDBM\\Filters\\FilterInterface')) {
1590 1590
 				$filter_bag2[] = $thing;
1591 1591
 			} elseif (is_string($thing)) {
1592 1592
 				$filter_bag2[] = new SqlStringFilter($thing);
1593
-			} elseif (is_a($thing,'Mouf\\Database\\TDBM\\TDBMObjectArray') && count($thing)>0) {
1593
+			} elseif (is_a($thing, 'Mouf\\Database\\TDBM\\TDBMObjectArray') && count($thing)>0) {
1594 1594
 				// Get table_name and column_name
1595 1595
 				$filter_table_name = $thing[0]->_getDbTableName();
1596 1596
 				$filter_column_names = $thing[0]->getPrimaryKey();
1597 1597
 
1598 1598
 				// If there is only one primary key, we can use the InFilter
1599
-				if (count($filter_column_names)==1) {
1599
+				if (count($filter_column_names) == 1) {
1600 1600
 					$primary_keys_array = array();
1601 1601
 					$filter_column_name = $filter_column_names[0];
1602 1602
 					foreach ($thing as $TDBMObject) {
@@ -1609,7 +1609,7 @@  discard block
 block discarded – undo
1609 1609
 				{
1610 1610
 					$filter_bag_and = array();
1611 1611
 					foreach ($thing as $TDBMObject) {
1612
-						$filter_bag_temp_and=array();
1612
+						$filter_bag_temp_and = array();
1613 1613
 						foreach ($filter_column_names as $pk) {
1614 1614
 							$filter_bag_temp_and[] = new EqualFilter($TDBMObject->_getDbTableName(), $pk, $TDBMObject->$pk);
1615 1615
 						}
@@ -1619,7 +1619,7 @@  discard block
 block discarded – undo
1619 1619
 				}
1620 1620
 
1621 1621
 
1622
-			} elseif (!is_a($thing,'Mouf\\Database\\TDBM\\TDBMObjectArray') && $thing!==null) {
1622
+			} elseif (!is_a($thing, 'Mouf\\Database\\TDBM\\TDBMObjectArray') && $thing !== null) {
1623 1623
 				throw new TDBMException("Error in filter bag in getObjectsByFilter. An object has been passed that is neither a filter, nor a TDBMObject, nor a TDBMObjectArray, nor a string, nor null.");
1624 1624
 			}
1625 1625
 		}
@@ -1647,9 +1647,9 @@  discard block
 block discarded – undo
1647 1647
 		// 4-2, let's take all the objects out of the orderby bag, and let's make objects from them
1648 1648
 		$orderby_bag2 = array();
1649 1649
 		foreach ($orderby_bag as $thing) {
1650
-			if (is_a($thing,'Mouf\\Database\\TDBM\\Filters\\OrderBySQLString')) {
1650
+			if (is_a($thing, 'Mouf\\Database\\TDBM\\Filters\\OrderBySQLString')) {
1651 1651
 				$orderby_bag2[] = $thing;
1652
-			} elseif (is_a($thing,'Mouf\\Database\\TDBM\\Filters\\OrderByColumn')) {
1652
+			} elseif (is_a($thing, 'Mouf\\Database\\TDBM\\Filters\\OrderByColumn')) {
1653 1653
 				$orderby_bag2[] = $thing;
1654 1654
 			} elseif (is_string($thing)) {
1655 1655
 				$orderby_bag2[] = new OrderBySQLString($thing);
@@ -1672,10 +1672,10 @@  discard block
 block discarded – undo
1672 1672
 			$possible_tables = $this->dbConnection->checkTableExist($table);
1673 1673
 			if ($possible_tables !== true)
1674 1674
 			{
1675
-				if (count($possible_tables)==1)
1675
+				if (count($possible_tables) == 1)
1676 1676
 				$str = "Could not find table '$table'. Maybe you meant this table: '".$possible_tables[0]."'";
1677 1677
 				else
1678
-				$str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$possible_tables)."'";
1678
+				$str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '", $possible_tables)."'";
1679 1679
 				throw new TDBMException($str);
1680 1680
 			}
1681 1681
 		}
@@ -1698,16 +1698,16 @@  discard block
 block discarded – undo
1698 1698
 			$current_node = $tree;
1699 1699
 			$found = true;
1700 1700
 			foreach ($path as $link) {
1701
-				if ($found==true)
1701
+				if ($found == true)
1702 1702
 				{
1703 1703
 					if (is_array($current_node->getChildren()))
1704 1704
 					{
1705 1705
 						foreach ($current_node->getChildren() as $child)
1706 1706
 						{
1707
-							if ($link['table1']==$child->table_name &&
1708
-							$link['col1']==$child->keyNode &&
1709
-							$link['col2']==$child->keyParent &&
1710
-							$link['type']==$child->link_type) {
1707
+							if ($link['table1'] == $child->table_name &&
1708
+							$link['col1'] == $child->keyNode &&
1709
+							$link['col2'] == $child->keyParent &&
1710
+							$link['type'] == $child->link_type) {
1711 1711
 								$current_node = $child;
1712 1712
 							}
1713 1713
 							else
@@ -1722,7 +1722,7 @@  discard block
 block discarded – undo
1722 1722
 
1723 1723
 				}
1724 1724
 
1725
-				if ($found==false)
1725
+				if ($found == false)
1726 1726
 				{
1727 1727
 					$current_node = new DisplayNode($link['table1'], $current_node, $link['type'], $link['col2'], $link['col1']);
1728 1728
 				}
@@ -1747,7 +1747,7 @@  discard block
 block discarded – undo
1747 1747
      *
1748 1748
      * @return string
1749 1749
 	 */
1750
-	public function drawTree($tree, $x, $y, &$ret_width=0, &$ret_height=0) {
1750
+	public function drawTree($tree, $x, $y, &$ret_width = 0, &$ret_height = 0) {
1751 1751
 
1752 1752
 		// Let's get the background div:
1753 1753
 		$treeDepth = $tree->computeDepth(1)-1;
@@ -1758,7 +1758,7 @@  discard block
 block discarded – undo
1758 1758
 
1759 1759
 		$str = "<div style='position:absolute; left:".($x+DisplayNode::$left_start-DisplayNode::$border)."px; top:".($y+DisplayNode::$top_start-DisplayNode::$border)."px; width:".$ret_width."px; height:".$ret_height."; background-color:#EEEEEE; color: white; text-align:center;'></div>";
1760 1760
 
1761
-		$str .= $tree->draw(0,0, $x, $y);
1761
+		$str .= $tree->draw(0, 0, $x, $y);
1762 1762
 
1763 1763
 		return $str;
1764 1764
 	}
@@ -1793,10 +1793,10 @@  discard block
 block discarded – undo
1793 1793
 				if ($tables === true)
1794 1794
 				throw new TDBMException("Could not find table primary key for table '$table'. Please define a primary key for this table.");
1795 1795
 				elseif ($tables !== null) {
1796
-					if (count($tables)==1)
1796
+					if (count($tables) == 1)
1797 1797
 					$str = "Could not find table '$table'. Maybe you meant this table: '".$tables[0]."'";
1798 1798
 					else
1799
-					$str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$tables)."'";
1799
+					$str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '", $tables)."'";
1800 1800
 					throw new TDBMException($str);
1801 1801
 				}
1802 1802
 			}
Please login to merge, or discard this patch.