Completed
Pull Request — 3.3 (#155)
by Thibault
04:23
created
src/Mouf/Database/TDBM/Filters/OrderBySQLString.php 1 patch
Braces   +19 added lines, -14 removed lines patch added patch discarded remove patch
@@ -87,8 +87,9 @@  discard block
 block discarded – undo
87 87
 			while (true) {
88 88
 				$result = strrpos($phrase, "'", $result+1);
89 89
 				if ($result===false) {
90
-					if ($sentence!='')
91
-					$sentence .= ',';
90
+					if ($sentence!='') {
91
+										$sentence .= ',';
92
+					}
92 93
 					$sentence .= $phrase;
93 94
 
94 95
 					if ($is_inside_quotes) {
@@ -98,15 +99,15 @@  discard block
 block discarded – undo
98 99
 						$sentence = '';
99 100
 						break;
100 101
 					}
101
-				}
102
-				else
102
+				} else
103 103
 				{
104 104
 					$valid_result = true;
105 105
 					if ($result>0 && $phrase{$result-1}=='\\') {
106 106
 						$valid_result = false;
107 107
 					}
108
-					if ($valid_result)
109
-					$is_inside_quotes = !$is_inside_quotes;
108
+					if ($valid_result) {
109
+										$is_inside_quotes = !$is_inside_quotes;
110
+					}
110 111
 				}
111 112
 			}
112 113
 
@@ -132,23 +133,27 @@  discard block
 block discarded – undo
132 133
 		// Now, let's split the string using '
133 134
 		$work_table = explode("'", $work_str);
134 135
 
135
-		if (count($work_table) == 0)
136
-		    return '';
136
+		if (count($work_table) == 0) {
137
+				    return '';
138
+		}
137 139
 
138 140
 		// if we start with a ', let's remove the first text
139
-		if (strstr($work_str,"'") === 0)
140
-		    array_shift($work_table);
141
+		if (strstr($work_str,"'") === 0) {
142
+				    array_shift($work_table);
143
+		}
141 144
 			
142
-		if (count($work_table) == 0)
143
-		    return '';
145
+		if (count($work_table) == 0) {
146
+				    return '';
147
+		}
144 148
 
145 149
 		// Now, let's take only the stuff outside the quotes.
146 150
 		$work_str2 = '';
147 151
 
148 152
 		$i = 0;
149 153
 		foreach ($work_table as $str_fragment) {
150
-			if (($i % 2) == 0)
151
-			$work_str2 .= $str_fragment.' ';
154
+			if (($i % 2) == 0) {
155
+						$work_str2 .= $str_fragment.' ';
156
+			}
152 157
 			$i++;
153 158
 		}
154 159
 
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/SqlStringFilter.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -99,23 +99,27 @@
 block discarded – undo
99 99
 		// Now, let's split the string using '
100 100
 		$work_table = explode("'", $work_str);
101 101
 
102
-		if (count($work_table)==0)
103
-		return '';
102
+		if (count($work_table)==0) {
103
+				return '';
104
+		}
104 105
 
105 106
 		// if we start with a ', let's remove the first text
106
-		if (strstr($work_str,"'")===0)
107
-		array_shift($work_table);
107
+		if (strstr($work_str,"'")===0) {
108
+				array_shift($work_table);
109
+		}
108 110
 			
109
-		if (count($work_table)==0)
110
-		return '';
111
+		if (count($work_table)==0) {
112
+				return '';
113
+		}
111 114
 
112 115
 		// Now, let's take only the stuff outside the quotes.
113 116
 		$work_str2 = '';
114 117
 
115 118
 		$i=0;
116 119
 		foreach ($work_table as $str_fragment) {
117
-			if (($i % 2) == 0)
118
-			$work_str2 .= $str_fragment.' ';
120
+			if (($i % 2) == 0) {
121
+						$work_str2 .= $str_fragment.' ';
122
+			}
119 123
 			$i++;
120 124
 		}
121 125
 
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/AmbiguityException.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -50,8 +50,9 @@  discard block
 block discarded – undo
50 50
 
51 51
 	private static function getAllPossiblePathsRec($sub_table_paths)
52 52
 	{
53
-		if (count($sub_table_paths)==0)
54
-		return array();
53
+		if (count($sub_table_paths)==0) {
54
+				return array();
55
+		}
55 56
 
56 57
 		$table_path = array_shift($sub_table_paths);
57 58
 		$possible_sub_paths =  AmbiguityException::getAllPossiblePathsRec($sub_table_paths);
@@ -63,9 +64,9 @@  discard block
 block discarded – undo
63 64
 				{
64 65
 					$return_table_paths[] = array_merge(array(array('paths'=>array($path))), $possible_sub_path);
65 66
 				}
67
+			} else {
68
+						$return_table_paths[] = array(array('paths'=>array($path)));
66 69
 			}
67
-			else
68
-			$return_table_paths[] = array(array('paths'=>array($path)));
69 70
 		}
70 71
 		return $return_table_paths;
71 72
 	}
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/TDBMObjectArray.php 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -31,12 +31,10 @@  discard block
 block discarded – undo
31 31
 		if ($cnt==1)
32 32
 		{
33 33
 			return $this[0]->__get($var);
34
-		}
35
-		elseif ($cnt>1)
34
+		} elseif ($cnt>1)
36 35
 		{
37 36
 			throw new TDBMException('Array contains many objects! Use getarray_'.$var.' to retrieve an array of '.$var);
38
-		}
39
-		else
37
+		} else
40 38
 		{
41 39
 			throw new TDBMException('Array contains no objects');
42 40
 		}
@@ -47,12 +45,10 @@  discard block
 block discarded – undo
47 45
 		if ($cnt==1)
48 46
 		{
49 47
 			return $this[0]->__set($var, $value);
50
-		}
51
-		elseif ($cnt>1)
48
+		} elseif ($cnt>1)
52 49
 		{
53 50
 			throw new TDBMException('Array contains many objects! Use setarray_'.$var.' to set the array of '.$var);
54
-		}
55
-		else
51
+		} else
56 52
 		{
57 53
 			throw new TDBMException('Array contains no objects');
58 54
 		}
@@ -77,8 +73,7 @@  discard block
 block discarded – undo
77 73
 			return $this->setarray($column, $values[0]);
78 74
 		} elseif (count($this)==1) {
79 75
 			$this[0]->__call($func_name, $values);
80
-		}
81
-		else
76
+		} else
82 77
 		{
83 78
 			throw new TDBMException("Method ".$func_name." not found");
84 79
 		}
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/DisplayNode.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -67,8 +67,7 @@
 block discarded – undo
67 67
 			if ($this->link_type == "*1")
68 68
 			{
69 69
 				echo "Table $this->table_name points to table ".$this->parent_node->table_name." through its foreign key on column $this->keyNode that points to column $this->keyParent<br />";
70
-			}
71
-			else if ($this->link_type == "1*")
70
+			} else if ($this->link_type == "1*")
72 71
 			{
73 72
 				echo "Table $this->table_name is pointed by table ".$this->parent_node->table_name." by its foreign key on column $this->keyParent that points to column $this->keyNode<br />";
74 73
 			}
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/TDBMObject.php 1 patch
Braces   +30 added lines, -23 removed lines patch added patch discarded remove patch
@@ -263,10 +263,11 @@  discard block
 block discarded – undo
263 263
 				// Let's try to be accurate in error reporting. The checkColumnExist returns an array of closest matches.
264 264
 				$result_array = $column_exist;
265 265
 				
266
-				if (count($result_array)==1)
267
-				$str = "Could not find column \"$var\" in table \"$this->db_table_name\". Maybe you meant this column: '".$result_array[0]."'";
268
-				else
269
-				$str = "Could not find column \"$var\" in table \"$this->db_table_name\". Maybe you meant one of those columns: '".implode("', '",$result_array)."'";
266
+				if (count($result_array)==1) {
267
+								$str = "Could not find column \"$var\" in table \"$this->db_table_name\". Maybe you meant this column: '".$result_array[0]."'";
268
+				} else {
269
+								$str = "Could not find column \"$var\" in table \"$this->db_table_name\". Maybe you meant one of those columns: '".implode("', '",$result_array)."'";
270
+				}
270 271
 	
271 272
 	
272 273
 				throw new TDBMException($str);
@@ -348,10 +349,11 @@  discard block
 block discarded – undo
348 349
 			if (count($pk_array)>1 && !$pk_set) {
349 350
 				$msg = "Error! You did not set the primary keys for the new object of type '$this->db_table_name'. TDBM usually assumes that the primary key is automatically set by the DB engine to the maximum value in the database. However, in this case, the '$this->db_table_name' table has a primary key on multiple columns. TDBM would be unable to find back this record after save. Please specify the primary keys for all new objects of kind '$this->db_table_name'.";
350 351
 
351
-				if (!$this->tdbmService->isProgramExiting())
352
-				throw new TDBMException($msg);
353
-				else
354
-				trigger_error($msg, E_USER_ERROR);
352
+				if (!$this->tdbmService->isProgramExiting()) {
353
+								throw new TDBMException($msg);
354
+				} else {
355
+								trigger_error($msg, E_USER_ERROR);
356
+				}
355 357
 			}
356 358
 			
357 359
 			$sql = 'INSERT INTO '.$this->db_connection->escapeDBItem($this->db_table_name).
@@ -360,8 +362,9 @@  discard block
 block discarded – undo
360 362
 
361 363
 			$first = true;
362 364
 			foreach ($this->db_row as $key=>$value) {
363
-				if (!$first)
364
-				$sql .= ',';
365
+				if (!$first) {
366
+								$sql .= ',';
367
+				}
365 368
 				$sql .= $this->db_connection->quoteSmart($value);
366 369
 				$first=false;
367 370
 			}
@@ -378,9 +381,9 @@  discard block
 block discarded – undo
378 381
 				//	trigger_error("program exiting");
379 382
 				trigger_error($e->getMessage(), E_USER_ERROR);
380 383
 
381
-				if (!$this->tdbmService->isProgramExiting())
382
-				throw $e;
383
-				else
384
+				if (!$this->tdbmService->isProgramExiting()) {
385
+								throw $e;
386
+				} else
384 387
 				{
385 388
 					trigger_error($e->getMessage(), E_USER_ERROR);
386 389
 				}
@@ -447,8 +450,9 @@  discard block
 block discarded – undo
447 450
 
448 451
 			$first = true;
449 452
 			foreach ($this->db_row as $key=>$value) {
450
-				if (!$first)
451
-				$sql .= ',';
453
+				if (!$first) {
454
+								$sql .= ',';
455
+				}
452 456
 				$sql .= $this->db_connection->escapeDBItem($key)." = ".$this->db_connection->quoteSmart($value);
453 457
 				$first=false;
454 458
 			}
@@ -456,10 +460,11 @@  discard block
 block discarded – undo
456 460
 			try {
457 461
 				$this->db_connection->exec($sql);
458 462
 			} catch (TDBMException $e) {
459
-				if (!$this->tdbmService->isProgramExiting())
460
-				throw $e;
461
-				else
462
-				trigger_error($e->getMessage(), E_USER_ERROR);
463
+				if (!$this->tdbmService->isProgramExiting()) {
464
+								throw $e;
465
+				} else {
466
+								trigger_error($e->getMessage(), E_USER_ERROR);
467
+				}
463 468
 			}
464 469
 
465 470
 			// Let's remove this object from the $new_objects static table.
@@ -490,11 +495,13 @@  discard block
 block discarded – undo
490 495
 	 *
491 496
 	 */
492 497
 	public function discardChanges() {
493
-		if ($this->TDBMObject_state == "new")
494
-		throw new TDBMException("You cannot call discardChanges() on an object that has been created with getNewObject and that has not yet been saved.");
498
+		if ($this->TDBMObject_state == "new") {
499
+				throw new TDBMException("You cannot call discardChanges() on an object that has been created with getNewObject and that has not yet been saved.");
500
+		}
495 501
 
496
-		if ($this->TDBMObject_state == "deleted")
497
-		throw new TDBMException("You cannot call discardChanges() on an object that has been deleted.");
502
+		if ($this->TDBMObject_state == "deleted") {
503
+				throw new TDBMException("You cannot call discardChanges() on an object that has been deleted.");
504
+		}
498 505
 			
499 506
 		$this->db_modified_state = false;
500 507
 		$this->TDBMObject_state = "not loaded";
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/TDBMObjectArrayCursorIterator.php 1 patch
Braces   +14 added lines, -12 removed lines patch added patch discarded remove patch
@@ -101,8 +101,7 @@  discard block
 block discarded – undo
101 101
 				throw new TDBMException("Bad SQL request passed to getObjectsFromSQL. The SQL request should return all the rows from the '".$this->table_name."' table. Could not find primary key in this set of rows. SQL request passed: ".$this->sql);
102 102
 			}
103 103
 			$id = $row[$this->keysStandardCased[$this->primary_keys[0]]];
104
-		}
105
-		else
104
+		} else
106 105
 		{
107 106
 			// Let's generate the serialized primary key from the columns!
108 107
 			$ids = array();
@@ -181,12 +180,14 @@  discard block
 block discarded – undo
181 180
 		if ($this->hasNext()) {
182 181
 			$this->cursor++;
183 182
 			$this->current = $this->pdoStatement->fetch(\PDO::FETCH_ASSOC);
184
-			if (empty($this->current))
185
-				$this->current = false;
186
-			else
187
-				return true;
188
-		}else
189
-			$this->current = false;
183
+			if (empty($this->current)) {
184
+							$this->current = false;
185
+			} else {
186
+							return true;
187
+			}
188
+		} else {
189
+					$this->current = false;
190
+		}
190 191
 		return false;
191 192
 	}
192 193
 	
@@ -259,10 +260,11 @@  discard block
 block discarded – undo
259 260
 		$all = array();
260 261
 		$this->rewind();
261 262
 		foreach ($this->pdoStatement as $id => $doc) {
262
-			if ($asRecords)
263
-				$all[$id] = $this->cast($doc);
264
-			else
265
-				$all[$id] = $doc;
263
+			if ($asRecords) {
264
+							$all[$id] = $this->cast($doc);
265
+			} else {
266
+							$all[$id] = $doc;
267
+			}
266 268
 		}
267 269
 		return $all;
268 270
 	}
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Utils/TDBMDaoGenerator.php 1 patch
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 				$defaultSort = $data['column_name'];
427 427
 				if (count($matches == 3)){
428 428
 					$defaultSortDirection = $matches[2];
429
-				}else{
429
+				} else{
430 430
 					$defaultSortDirection = 'ASC';
431 431
 				}
432 432
 			}
@@ -836,8 +836,9 @@  discard block
 block discarded – undo
836 836
 	public static function toCamelCase($str) {
837 837
 		$str = strtoupper(substr($str,0,1)).substr($str,1);
838 838
 		while (true) {
839
-			if (strpos($str, "_") === false && strpos($str, " ") === false)
840
-				break;
839
+			if (strpos($str, "_") === false && strpos($str, " ") === false) {
840
+							break;
841
+			}
841 842
 				
842 843
 			$pos = strpos($str, "_");
843 844
 			if ($pos === false) {
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/TDBMService.php 1 patch
Braces   +60 added lines, -57 removed lines patch added patch discarded remove patch
@@ -446,10 +446,11 @@  discard block
 block discarded – undo
446 446
 			/*$data =*/ $this->dbConnection->getTableInfo($table_name);
447 447
 		} catch (TDBMException $exception) {
448 448
 			$probable_table_name = $this->dbConnection->checkTableExist($table_name);
449
-			if ($probable_table_name == null)
450
-			throw new TDBMException("Error while calling TDBMObject::getNewObject(): The table named '$table_name' does not exist.");
451
-			else
452
-			throw new TDBMException("Error while calling TDBMObject::getNewObject(): The table named '$table_name' does not exist. Maybe you meant the table '$probable_table_name'.");
449
+			if ($probable_table_name == null) {
450
+						throw new TDBMException("Error while calling TDBMObject::getNewObject(): The table named '$table_name' does not exist.");
451
+			} else {
452
+						throw new TDBMException("Error while calling TDBMObject::getNewObject(): The table named '$table_name' does not exist. Maybe you meant the table '$probable_table_name'.");
453
+			}
453 454
 		}
454 455
 
455 456
 		if ($className == null) {
@@ -523,8 +524,9 @@  discard block
 block discarded – undo
523 524
 			$sql = 'DELETE FROM '.$this->dbConnection->escapeDBItem($object->_getDbTableName()).' WHERE '.$sql_where;
524 525
 			$result = $this->dbConnection->exec($sql);
525 526
 
526
-			if ($result != 1)
527
-			throw new TDBMException("Error while deleting object from table ".$object->_getDbTableName().": ".$result." have been affected.");
527
+			if ($result != 1) {
528
+						throw new TDBMException("Error while deleting object from table ".$object->_getDbTableName().": ".$result." have been affected.");
529
+			}
528 530
 
529 531
 			$this->objectStorage->remove($object->_getDbTableName(), $object_id);
530 532
 			$object->setTDBMObjectState("deleted");
@@ -639,8 +641,7 @@  discard block
 block discarded – undo
639 641
 						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);
640 642
 					}
641 643
 					$id = $row[$keysStandardCased[$pk_table[0]]];
642
-				}
643
-				else
644
+				} else
644 645
 				{
645 646
 					// Let's generate the serialized primary key from the columns!
646 647
 					$ids = array();
@@ -724,8 +725,7 @@  discard block
 block discarded – undo
724 725
 					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);
725 726
 				}
726 727
 				$id = $row[$keysStandardCased[$pk_table[0]]];
727
-			}
728
-			else
728
+			} else
729 729
 			{
730 730
 				// Let's generate the serialized primary key from the columns!
731 731
 				$ids = array();
@@ -894,8 +894,7 @@  discard block
 block discarded – undo
894 894
 		foreach ($path as $constraint) {
895 895
 			if ($constraint['type']=='1*') {
896 896
 				$msg .= 'Table "'.$constraint['table1'].'" points to "'.$constraint['table2'].'" through its foreign key "'.$constraint['col1'].'"\n';
897
-			}
898
-			elseif ($constraint['type']=='*1') {
897
+			} elseif ($constraint['type']=='*1') {
899 898
 				$msg .= 'Table "'.$constraint['table1'].'" is pointed by "'.$constraint['table2'].'" through its foreign key "'.$constraint['col2'].'"\n';
900 899
 			}
901 900
 		}
@@ -983,8 +982,9 @@  discard block
 block discarded – undo
983 982
 			// If any table has more than 1 way to be reached, throw an exception.
984 983
 			if (count($table_path['paths'])>1) {
985 984
 				// If this is the first ambiguity
986
-				if (!$ambiguity)
987
-				$msg .= 'An ambiguity has been found during the search. Please catch this exception and execute the $exception->explainAmbiguity() to get a nice graphical view of what you should do to solve this ambiguity.';
985
+				if (!$ambiguity) {
986
+								$msg .= 'An ambiguity has been found during the search. Please catch this exception and execute the $exception->explainAmbiguity() to get a nice graphical view of what you should do to solve this ambiguity.';
987
+				}
988 988
 
989 989
 				$msg .= "The table \"".$table_path['name']."\" can be reached using several different ways from the table \"$table\".\n\n";
990 990
 				$count = 0;
@@ -1025,8 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 		if (isset($this->cache['paths'][$table1][$table2]))
1026 1026
 		{
1027 1027
 			return $this->cache['paths'][$table1][$table2];
1028
-		}
1029
-		elseif (isset($this->cache['paths'][$table2][$table1]))
1028
+		} elseif (isset($this->cache['paths'][$table2][$table1]))
1030 1029
 		{
1031 1030
 			// Let's revert the path!
1032 1031
 			$toRevertPath = $this->cache['paths'][$table2][$table1];
@@ -1071,8 +1070,9 @@  discard block
 block discarded – undo
1071 1070
 						break;
1072 1071
 					}
1073 1072
 				}
1074
-				if (!$found)
1075
-				$flat_path[] = $path_step;
1073
+				if (!$found) {
1074
+								$flat_path[] = $path_step;
1075
+				}
1076 1076
 			}
1077 1077
 		}
1078 1078
 		return $flat_path;
@@ -1107,8 +1107,9 @@  discard block
 block discarded – undo
1107 1107
 					}
1108 1108
 				}
1109 1109
 
1110
-				if ($found)
1111
-				return true;
1110
+				if ($found) {
1111
+								return true;
1112
+				}
1112 1113
 			}
1113 1114
 
1114 1115
 		}
@@ -1131,16 +1132,16 @@  discard block
 block discarded – undo
1131 1132
 					//echo "YOUHOU1! $current_table $col2";
1132 1133
 					$already_done = true;
1133 1134
 					break;
1134
-				}
1135
-				elseif ($previous_constraint['type']=='*1' && $current_table == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"] && $table1 == $previous_constraint["table2"] && $col1 == $previous_constraint["col2"])
1135
+				} elseif ($previous_constraint['type']=='*1' && $current_table == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"] && $table1 == $previous_constraint["table2"] && $col1 == $previous_constraint["col2"])
1136 1136
 				{
1137 1137
 					//echo "YOUHOU2! $current_table $col2";
1138 1138
 					$already_done = true;
1139 1139
 					break;
1140 1140
 				}
1141 1141
 			}
1142
-			if ($already_done)
1143
-			continue;
1142
+			if ($already_done) {
1143
+						continue;
1144
+			}
1144 1145
 
1145 1146
 			$new_path = array_merge($path, array(array("table1"=>$table1,
1146 1147
 									"col1"=>$col1,
@@ -1165,15 +1166,15 @@  discard block
 block discarded – undo
1165 1166
 				{
1166 1167
 					$already_done = true;
1167 1168
 					break;
1168
-				}
1169
-				elseif ($previous_constraint['type']=='*1' && $table2 == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"])
1169
+				} elseif ($previous_constraint['type']=='*1' && $table2 == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"])
1170 1170
 				{
1171 1171
 					$already_done = true;
1172 1172
 					break;
1173 1173
 				}
1174 1174
 			}
1175
-			if ($already_done)
1176
-			continue;
1175
+			if ($already_done) {
1176
+						continue;
1177
+			}
1177 1178
 
1178 1179
 			$new_path = array_merge($path, array(array("table1"=>$table2,
1179 1180
 									"col1"=>$col2,
@@ -1413,16 +1414,15 @@  discard block
 block discarded – undo
1413 1414
 		{
1414 1415
 			$sql = $this->dbConnection->escapeDBItem($table_name); //Make by Pierre PIV (add escapeDBItem)
1415 1416
 
1416
-			if ($mode == 'explainTree')
1417
-			throw new TDBMException("TODO: explainTree not implemented for only one table.");
1418
-		}
1419
-		else {
1417
+			if ($mode == 'explainTree') {
1418
+						throw new TDBMException("TODO: explainTree not implemented for only one table.");
1419
+			}
1420
+		} else {
1420 1421
 			if ($hint_path!=null && $mode != 'explainTree')
1421 1422
 			{
1422 1423
 				$path = $hint_path;
1423 1424
 				$flat_path = $this->flatten_paths($path);
1424
-			}
1425
-			else
1425
+			} else
1426 1426
 			{
1427 1427
 				$full_paths = $this->static_find_paths($table_name,$needed_table_array);
1428 1428
 
@@ -1530,8 +1530,9 @@  discard block
 block discarded – undo
1530 1530
 			$sql = "SELECT COUNT(DISTINCT $pk_str) FROM $sql";
1531 1531
 
1532 1532
 			$where_clause = $filter->toSql($this->dbConnection);
1533
-			if ($where_clause != '')
1534
-			$sql .= ' WHERE '.$where_clause;
1533
+			if ($where_clause != '') {
1534
+						$sql .= ' WHERE '.$where_clause;
1535
+			}
1535 1536
 
1536 1537
 			// Now, let's perform the request:
1537 1538
 			$result = $this->dbConnection->getOne($sql, array());
@@ -1542,8 +1543,9 @@  discard block
 block discarded – undo
1542 1543
 		$sql = "SELECT DISTINCT ".$this->dbConnection->escapeDBItem($table_name).".* $orderby_column_statement FROM $sql";
1543 1544
 
1544 1545
 		$where_clause = $filter->toSql($this->dbConnection);
1545
-		if ($where_clause != '')
1546
-		$sql .= ' WHERE '.$where_clause;
1546
+		if ($where_clause != '') {
1547
+				$sql .= ' WHERE '.$where_clause;
1548
+		}
1547 1549
 
1548 1550
 		$sql .= $orderby_statement;
1549 1551
 
@@ -1568,8 +1570,7 @@  discard block
 block discarded – undo
1568 1570
 			$filter_bag = array();
1569 1571
 		} elseif (!is_array($filter_bag)) {
1570 1572
 			$filter_bag = array($filter_bag);
1571
-		}
1572
-		elseif (is_a($filter_bag, 'Mouf\\Database\\TDBM\\TDBMObjectArray')) {
1573
+		} elseif (is_a($filter_bag, 'Mouf\\Database\\TDBM\\TDBMObjectArray')) {
1573 1574
 			$filter_bag = array($filter_bag);
1574 1575
 		}
1575 1576
 
@@ -1631,8 +1632,9 @@  discard block
 block discarded – undo
1631 1632
 		// Fourth, let's apply the same steps to the orderby_bag
1632 1633
 		// 4-1 orderby_bag should be an array, if it is a singleton, let's put it in an array.
1633 1634
 
1634
-		if (!is_array($orderby_bag))
1635
-		$orderby_bag = array($orderby_bag);
1635
+		if (!is_array($orderby_bag)) {
1636
+				$orderby_bag = array($orderby_bag);
1637
+		}
1636 1638
 
1637 1639
 		// 4-2, let's take all the objects out of the orderby bag, and let's make objects from them
1638 1640
 		$orderby_bag2 = array();
@@ -1662,10 +1664,11 @@  discard block
 block discarded – undo
1662 1664
 			$possible_tables = $this->dbConnection->checkTableExist($table);
1663 1665
 			if ($possible_tables !== true)
1664 1666
 			{
1665
-				if (count($possible_tables)==1)
1666
-				$str = "Could not find table '$table'. Maybe you meant this table: '".$possible_tables[0]."'";
1667
-				else
1668
-				$str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$possible_tables)."'";
1667
+				if (count($possible_tables)==1) {
1668
+								$str = "Could not find table '$table'. Maybe you meant this table: '".$possible_tables[0]."'";
1669
+				} else {
1670
+								$str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$possible_tables)."'";
1671
+				}
1669 1672
 				throw new TDBMException($str);
1670 1673
 			}
1671 1674
 		}
@@ -1699,16 +1702,15 @@  discard block
 block discarded – undo
1699 1702
 							$link['col2']==$child->keyParent &&
1700 1703
 							$link['type']==$child->link_type) {
1701 1704
 								$current_node = $child;
1702
-							}
1703
-							else
1705
+							} else
1704 1706
 							{
1705 1707
 								// Now, we must add the rest of the links to the tree.
1706 1708
 								$found = false;
1707 1709
 							}
1708 1710
 						}
1711
+					} else {
1712
+										$found = false;
1709 1713
 					}
1710
-					else
1711
-					$found = false;
1712 1714
 
1713 1715
 				}
1714 1716
 
@@ -1780,13 +1782,14 @@  discard block
 block discarded – undo
1780 1782
 				// Unable to find primary key.... this is an error
1781 1783
 				// Let's try to be precise in error reporting. Let's try to find the table.
1782 1784
 				$tables = $this->dbConnection->checkTableExist($table);
1783
-				if ($tables === true)
1784
-				throw new TDBMException("Could not find table primary key for table '$table'. Please define a primary key for this table.");
1785
-				elseif ($tables !== null) {
1786
-					if (count($tables)==1)
1787
-					$str = "Could not find table '$table'. Maybe you meant this table: '".$tables[0]."'";
1788
-					else
1789
-					$str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$tables)."'";
1785
+				if ($tables === true) {
1786
+								throw new TDBMException("Could not find table primary key for table '$table'. Please define a primary key for this table.");
1787
+				} elseif ($tables !== null) {
1788
+					if (count($tables)==1) {
1789
+										$str = "Could not find table '$table'. Maybe you meant this table: '".$tables[0]."'";
1790
+					} else {
1791
+										$str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$tables)."'";
1792
+					}
1790 1793
 					throw new TDBMException($str);
1791 1794
 				}
1792 1795
 			}
Please login to merge, or discard this patch.