Passed
Pull Request — 3.4 (#159)
by David
06:38 queued 01:18
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/TDBMService.php 1 patch
Braces   +60 added lines, -57 removed lines patch added patch discarded remove patch
@@ -456,10 +456,11 @@  discard block
 block discarded – undo
456 456
 			/*$data =*/ $this->dbConnection->getTableInfo($table_name);
457 457
 		} catch (TDBMException $exception) {
458 458
 			$probable_table_name = $this->dbConnection->checkTableExist($table_name);
459
-			if ($probable_table_name == null)
460
-			throw new TDBMException("Error while calling TDBMObject::getNewObject(): The table named '$table_name' does not exist.");
461
-			else
462
-			throw new TDBMException("Error while calling TDBMObject::getNewObject(): The table named '$table_name' does not exist. Maybe you meant the table '$probable_table_name'.");
459
+			if ($probable_table_name == null) {
460
+						throw new TDBMException("Error while calling TDBMObject::getNewObject(): The table named '$table_name' does not exist.");
461
+			} else {
462
+						throw new TDBMException("Error while calling TDBMObject::getNewObject(): The table named '$table_name' does not exist. Maybe you meant the table '$probable_table_name'.");
463
+			}
463 464
 		}
464 465
 
465 466
 		if ($className === null) {
@@ -537,8 +538,9 @@  discard block
 block discarded – undo
537 538
 			$sql = 'DELETE FROM '.$this->dbConnection->escapeDBItem($object->_getDbTableName()).' WHERE '.$sql_where;
538 539
 			$result = $this->dbConnection->exec($sql);
539 540
 
540
-			if ($result != 1)
541
-			throw new TDBMException("Error while deleting object from table ".$object->_getDbTableName().": ".$result." have been affected.");
541
+			if ($result != 1) {
542
+						throw new TDBMException("Error while deleting object from table ".$object->_getDbTableName().": ".$result." have been affected.");
543
+			}
542 544
 
543 545
 			$this->objectStorage->remove($object->_getDbTableName(), $object_id);
544 546
 			$object->setTDBMObjectState("deleted");
@@ -665,8 +667,7 @@  discard block
 block discarded – undo
665 667
 						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);
666 668
 					}
667 669
 					$id = $row[$keysStandardCased[$pk_table[0]]];
668
-				}
669
-				else
670
+				} else
670 671
 				{
671 672
 					// Let's generate the serialized primary key from the columns!
672 673
 					$ids = array();
@@ -740,8 +741,7 @@  discard block
 block discarded – undo
740 741
 					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);
741 742
 				}
742 743
 				$id = $row[$keysStandardCased[$pk_table[0]]];
743
-			}
744
-			else
744
+			} else
745 745
 			{
746 746
 				// Let's generate the serialized primary key from the columns!
747 747
 				$ids = array();
@@ -910,8 +910,7 @@  discard block
 block discarded – undo
910 910
 		foreach ($path as $constraint) {
911 911
 			if ($constraint['type']=='1*') {
912 912
 				$msg .= 'Table "'.$constraint['table1'].'" points to "'.$constraint['table2'].'" through its foreign key "'.$constraint['col1'].'"\n';
913
-			}
914
-			elseif ($constraint['type']=='*1') {
913
+			} elseif ($constraint['type']=='*1') {
915 914
 				$msg .= 'Table "'.$constraint['table1'].'" is pointed by "'.$constraint['table2'].'" through its foreign key "'.$constraint['col2'].'"\n';
916 915
 			}
917 916
 		}
@@ -999,8 +998,9 @@  discard block
 block discarded – undo
999 998
 			// If any table has more than 1 way to be reached, throw an exception.
1000 999
 			if (count($table_path['paths'])>1) {
1001 1000
 				// If this is the first ambiguity
1002
-				if (!$ambiguity)
1003
-				$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.';
1001
+				if (!$ambiguity) {
1002
+								$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.';
1003
+				}
1004 1004
 
1005 1005
 				$msg .= "The table \"".$table_path['name']."\" can be reached using several different ways from the table \"$table\".\n\n";
1006 1006
 				$count = 0;
@@ -1041,8 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 		if (isset($this->cache['paths'][$table1][$table2]))
1042 1042
 		{
1043 1043
 			return $this->cache['paths'][$table1][$table2];
1044
-		}
1045
-		elseif (isset($this->cache['paths'][$table2][$table1]))
1044
+		} elseif (isset($this->cache['paths'][$table2][$table1]))
1046 1045
 		{
1047 1046
 			// Let's revert the path!
1048 1047
 			$toRevertPath = $this->cache['paths'][$table2][$table1];
@@ -1087,8 +1086,9 @@  discard block
 block discarded – undo
1087 1086
 						break;
1088 1087
 					}
1089 1088
 				}
1090
-				if (!$found)
1091
-				$flat_path[] = $path_step;
1089
+				if (!$found) {
1090
+								$flat_path[] = $path_step;
1091
+				}
1092 1092
 			}
1093 1093
 		}
1094 1094
 		return $flat_path;
@@ -1123,8 +1123,9 @@  discard block
 block discarded – undo
1123 1123
 					}
1124 1124
 				}
1125 1125
 
1126
-				if ($found)
1127
-				return true;
1126
+				if ($found) {
1127
+								return true;
1128
+				}
1128 1129
 			}
1129 1130
 
1130 1131
 		}
@@ -1146,15 +1147,15 @@  discard block
 block discarded – undo
1146 1147
 				{
1147 1148
 					$already_done = true;
1148 1149
 					break;
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;
1154 1154
 				}
1155 1155
 			}
1156
-			if ($already_done)
1157
-			continue;
1156
+			if ($already_done) {
1157
+						continue;
1158
+			}
1158 1159
 
1159 1160
 			$new_path = array_merge($path, array(array("table1"=>$table1,
1160 1161
 									"col1"=>$col1,
@@ -1179,15 +1180,15 @@  discard block
 block discarded – undo
1179 1180
 				{
1180 1181
 					$already_done = true;
1181 1182
 					break;
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;
1187 1187
 				}
1188 1188
 			}
1189
-			if ($already_done)
1190
-			continue;
1189
+			if ($already_done) {
1190
+						continue;
1191
+			}
1191 1192
 
1192 1193
 			$new_path = array_merge($path, array(array("table1"=>$table2,
1193 1194
 									"col1"=>$col2,
@@ -1427,16 +1428,15 @@  discard block
 block discarded – undo
1427 1428
 		{
1428 1429
 			$sql = $this->dbConnection->escapeDBItem($table_name); //Make by Pierre PIV (add escapeDBItem)
1429 1430
 
1430
-			if ($mode == 'explainTree')
1431
-			throw new TDBMException("TODO: explainTree not implemented for only one table.");
1432
-		}
1433
-		else {
1431
+			if ($mode == 'explainTree') {
1432
+						throw new TDBMException("TODO: explainTree not implemented for only one table.");
1433
+			}
1434
+		} else {
1434 1435
 			if ($hint_path!=null && $mode != 'explainTree')
1435 1436
 			{
1436 1437
 				$path = $hint_path;
1437 1438
 				$flat_path = $this->flatten_paths($path);
1438
-			}
1439
-			else
1439
+			} else
1440 1440
 			{
1441 1441
 				$full_paths = $this->static_find_paths($table_name,$needed_table_array);
1442 1442
 
@@ -1540,8 +1540,9 @@  discard block
 block discarded – undo
1540 1540
 			$sql = "SELECT COUNT(DISTINCT $pk_str) FROM $sql";
1541 1541
 
1542 1542
 			$where_clause = $filter->toSql($this->dbConnection);
1543
-			if ($where_clause != '')
1544
-			$sql .= ' WHERE '.$where_clause;
1543
+			if ($where_clause != '') {
1544
+						$sql .= ' WHERE '.$where_clause;
1545
+			}
1545 1546
 
1546 1547
 			// Now, let's perform the request:
1547 1548
 			$result = $this->dbConnection->getOne($sql, array());
@@ -1552,8 +1553,9 @@  discard block
 block discarded – undo
1552 1553
 		$sql = "SELECT DISTINCT ".$this->dbConnection->escapeDBItem($table_name).".* $orderby_column_statement FROM $sql";
1553 1554
 
1554 1555
 		$where_clause = $filter->toSql($this->dbConnection);
1555
-		if ($where_clause != '')
1556
-		$sql .= ' WHERE '.$where_clause;
1556
+		if ($where_clause != '') {
1557
+				$sql .= ' WHERE '.$where_clause;
1558
+		}
1557 1559
 
1558 1560
 		$sql .= $orderby_statement;
1559 1561
 
@@ -1578,8 +1580,7 @@  discard block
 block discarded – undo
1578 1580
 			$filter_bag = array();
1579 1581
 		} elseif (!is_array($filter_bag)) {
1580 1582
 			$filter_bag = array($filter_bag);
1581
-		}
1582
-		elseif (is_a($filter_bag, 'Mouf\\Database\\TDBM\\TDBMObjectArray')) {
1583
+		} elseif (is_a($filter_bag, 'Mouf\\Database\\TDBM\\TDBMObjectArray')) {
1583 1584
 			$filter_bag = array($filter_bag);
1584 1585
 		}
1585 1586
 
@@ -1641,8 +1642,9 @@  discard block
 block discarded – undo
1641 1642
 		// Fourth, let's apply the same steps to the orderby_bag
1642 1643
 		// 4-1 orderby_bag should be an array, if it is a singleton, let's put it in an array.
1643 1644
 
1644
-		if (!is_array($orderby_bag))
1645
-		$orderby_bag = array($orderby_bag);
1645
+		if (!is_array($orderby_bag)) {
1646
+				$orderby_bag = array($orderby_bag);
1647
+		}
1646 1648
 
1647 1649
 		// 4-2, let's take all the objects out of the orderby bag, and let's make objects from them
1648 1650
 		$orderby_bag2 = array();
@@ -1672,10 +1674,11 @@  discard block
 block discarded – undo
1672 1674
 			$possible_tables = $this->dbConnection->checkTableExist($table);
1673 1675
 			if ($possible_tables !== true)
1674 1676
 			{
1675
-				if (count($possible_tables)==1)
1676
-				$str = "Could not find table '$table'. Maybe you meant this table: '".$possible_tables[0]."'";
1677
-				else
1678
-				$str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$possible_tables)."'";
1677
+				if (count($possible_tables)==1) {
1678
+								$str = "Could not find table '$table'. Maybe you meant this table: '".$possible_tables[0]."'";
1679
+				} else {
1680
+								$str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$possible_tables)."'";
1681
+				}
1679 1682
 				throw new TDBMException($str);
1680 1683
 			}
1681 1684
 		}
@@ -1709,16 +1712,15 @@  discard block
 block discarded – undo
1709 1712
 							$link['col2']==$child->keyParent &&
1710 1713
 							$link['type']==$child->link_type) {
1711 1714
 								$current_node = $child;
1712
-							}
1713
-							else
1715
+							} else
1714 1716
 							{
1715 1717
 								// Now, we must add the rest of the links to the tree.
1716 1718
 								$found = false;
1717 1719
 							}
1718 1720
 						}
1721
+					} else {
1722
+										$found = false;
1719 1723
 					}
1720
-					else
1721
-					$found = false;
1722 1724
 
1723 1725
 				}
1724 1726
 
@@ -1790,13 +1792,14 @@  discard block
 block discarded – undo
1790 1792
 				// Unable to find primary key.... this is an error
1791 1793
 				// Let's try to be precise in error reporting. Let's try to find the table.
1792 1794
 				$tables = $this->dbConnection->checkTableExist($table);
1793
-				if ($tables === true)
1794
-				throw new TDBMException("Could not find table primary key for table '$table'. Please define a primary key for this table.");
1795
-				elseif ($tables !== null) {
1796
-					if (count($tables)==1)
1797
-					$str = "Could not find table '$table'. Maybe you meant this table: '".$tables[0]."'";
1798
-					else
1799
-					$str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$tables)."'";
1795
+				if ($tables === true) {
1796
+								throw new TDBMException("Could not find table primary key for table '$table'. Please define a primary key for this table.");
1797
+				} elseif ($tables !== null) {
1798
+					if (count($tables)==1) {
1799
+										$str = "Could not find table '$table'. Maybe you meant this table: '".$tables[0]."'";
1800
+					} else {
1801
+										$str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$tables)."'";
1802
+					}
1800 1803
 					throw new TDBMException($str);
1801 1804
 				}
1802 1805
 			}
Please login to merge, or discard this patch.