Completed
Push — 3.2 ( 7b06ed...40a0aa )
by David
09:20
created
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/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   +59 added lines, -55 removed lines patch added patch discarded remove patch
@@ -406,10 +406,11 @@  discard block
 block discarded – undo
406 406
 			$data = $this->dbConnection->getTableInfo($table_name);
407 407
 		} catch (TDBMException $exception) {
408 408
 			$probable_table_name = $this->dbConnection->checkTableExist($table_name);
409
-			if ($probable_table_name == null)
410
-			throw new TDBMException("Error while calling TDBMObject::getNewObject(): The table named '$table_name' does not exist.");
411
-			else
412
-			throw new TDBMException("Error while calling TDBMObject::getNewObject(): The table named '$table_name' does not exist. Maybe you meant the table '$probable_table_name'.");
409
+			if ($probable_table_name == null) {
410
+						throw new TDBMException("Error while calling TDBMObject::getNewObject(): The table named '$table_name' does not exist.");
411
+			} else {
412
+						throw new TDBMException("Error while calling TDBMObject::getNewObject(): The table named '$table_name' does not exist. Maybe you meant the table '$probable_table_name'.");
413
+			}
413 414
 		}
414 415
 
415 416
 		if ($className == null) {
@@ -484,8 +485,9 @@  discard block
 block discarded – undo
484 485
 			$sql = 'DELETE FROM '.$this->dbConnection->escapeDBItem($object->_getDbTableName()).' WHERE '.$sql_where/*.$primary_key."='".plainstring_to_dbprotected($object->TDBMObject_id)."'"*/;
485 486
 			$result = $this->dbConnection->exec($sql);
486 487
 
487
-			if ($result != 1)
488
-			throw new TDBMException("Error while deleting object from table ".$object->_getDbTableName().": ".$result." have been affected.");
488
+			if ($result != 1) {
489
+						throw new TDBMException("Error while deleting object from table ".$object->_getDbTableName().": ".$result." have been affected.");
490
+			}
489 491
 
490 492
 			unset ($this->objects[$object->_getDbTableName()][$object_id]);
491 493
 			$object->setTDBMObjectState("deleted");
@@ -556,8 +558,7 @@  discard block
 block discarded – undo
556 558
 					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);
557 559
 				}
558 560
 				$id = $row[$keysStandardCased[$pk_table[0]]];
559
-			}
560
-			else
561
+			} else
561 562
 			{
562 563
 				// Let's generate the serialized primary key from the columns!
563 564
 				$ids = array();
@@ -767,8 +768,7 @@  discard block
 block discarded – undo
767 768
 		foreach ($path as $constraint) {
768 769
 			if ($constraint['type']=='1*') {
769 770
 				$msg .= 'Table "'.$constraint['table1'].'" points to "'.$constraint['table2'].'" through its foreign key "'.$constraint['col1'].'"\n';
770
-			}
771
-			elseif ($constraint['type']=='*1') {
771
+			} elseif ($constraint['type']=='*1') {
772 772
 				$msg .= 'Table "'.$constraint['table1'].'" is pointed by "'.$constraint['table2'].'" through its foreign key "'.$constraint['col2'].'"\n';
773 773
 			}
774 774
 		}
@@ -858,8 +858,9 @@  discard block
 block discarded – undo
858 858
 			// If any table has more than 1 way to be reached, throw an exception.
859 859
 			if (count($table_path['paths'])>1) {
860 860
 				// If this is the first ambiguity
861
-				if (!$ambiguity)
862
-				$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.';
861
+				if (!$ambiguity) {
862
+								$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.';
863
+				}
863 864
 
864 865
 				$msg .= "The table \"".$table_path['name']."\" can be reached using several different ways from the table \"$table\".\n\n";
865 866
 				$count = 0;
@@ -903,8 +904,7 @@  discard block
 block discarded – undo
903 904
 		if (isset($this->cache['paths'][$table1][$table2]))
904 905
 		{
905 906
 			return $this->cache['paths'][$table1][$table2];
906
-		}
907
-		elseif (isset($this->cache['paths'][$table2][$table1]))
907
+		} elseif (isset($this->cache['paths'][$table2][$table1]))
908 908
 		{
909 909
 			// Let's revert the path!
910 910
 			$toRevertPath = $this->cache['paths'][$table2][$table1];
@@ -949,8 +949,9 @@  discard block
 block discarded – undo
949 949
 						break;
950 950
 					}
951 951
 				}
952
-				if (!$found)
953
-				$flat_path[] = $path_step;
952
+				if (!$found) {
953
+								$flat_path[] = $path_step;
954
+				}
954 955
 			}
955 956
 		}
956 957
 		return $flat_path;
@@ -988,8 +989,9 @@  discard block
 block discarded – undo
988 989
 					}
989 990
 				}
990 991
 
991
-				if ($found)
992
-				return true;
992
+				if ($found) {
993
+								return true;
994
+				}
993 995
 			}
994 996
 
995 997
 		}
@@ -1020,16 +1022,16 @@  discard block
 block discarded – undo
1020 1022
 					//echo "YOUHOU1! $current_table $col2";
1021 1023
 					$already_done = true;
1022 1024
 					break;
1023
-				}
1024
-				elseif ($previous_constraint['type']=='*1' && $current_table == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"] && $table1 == $previous_constraint["table2"] && $col1 == $previous_constraint["col2"])
1025
+				} elseif ($previous_constraint['type']=='*1' && $current_table == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"] && $table1 == $previous_constraint["table2"] && $col1 == $previous_constraint["col2"])
1025 1026
 				{
1026 1027
 					//echo "YOUHOU2! $current_table $col2";
1027 1028
 					$already_done = true;
1028 1029
 					break;
1029 1030
 				}
1030 1031
 			}
1031
-			if ($already_done)
1032
-			continue;
1032
+			if ($already_done) {
1033
+						continue;
1034
+			}
1033 1035
 
1034 1036
 			$new_path = array_merge($path, array(array("table1"=>$table1,
1035 1037
 									"col1"=>$col1,
@@ -1059,16 +1061,16 @@  discard block
 block discarded – undo
1059 1061
 					//echo  "YOUHOU3! $table2 $col2";
1060 1062
 					$already_done = true;
1061 1063
 					break;
1062
-				}
1063
-				elseif ($previous_constraint['type']=='*1' && $table2 == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"])
1064
+				} elseif ($previous_constraint['type']=='*1' && $table2 == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"])
1064 1065
 				{
1065 1066
 					//echo "YOUHOU4! $table2 $col2";
1066 1067
 					$already_done = true;
1067 1068
 					break;
1068 1069
 				}
1069 1070
 			}
1070
-			if ($already_done)
1071
-			continue;
1071
+			if ($already_done) {
1072
+						continue;
1073
+			}
1072 1074
 
1073 1075
 			$new_path = array_merge($path, array(array("table1"=>$table2,
1074 1076
 									"col1"=>$col2,
@@ -1309,16 +1311,15 @@  discard block
 block discarded – undo
1309 1311
 			$table_number = 1;
1310 1312
 			$sql = $this->dbConnection->escapeDBItem($table_name); //Make by Pierre PIV (add escapeDBItem)
1311 1313
 
1312
-			if ($mode == 'explainTree')
1313
-			throw new TDBMException("TODO: explainTree not implemented for only one table.");
1314
-		}
1315
-		else {
1314
+			if ($mode == 'explainTree') {
1315
+						throw new TDBMException("TODO: explainTree not implemented for only one table.");
1316
+			}
1317
+		} else {
1316 1318
 			if ($hint_path!=null && $mode != 'explainTree')
1317 1319
 			{
1318 1320
 				$path = $hint_path;
1319 1321
 				$flat_path = $this->flatten_paths($path);
1320
-			}
1321
-			else
1322
+			} else
1322 1323
 			{
1323 1324
 				$full_paths = $this->static_find_paths($table_name,$needed_table_array);
1324 1325
 
@@ -1432,8 +1433,9 @@  discard block
 block discarded – undo
1432 1433
 			$sql = "SELECT COUNT(DISTINCT $pk_str) FROM $sql";
1433 1434
 
1434 1435
 			$where_clause = $filter->toSql($this->dbConnection);
1435
-			if ($where_clause != '')
1436
-			$sql .= ' WHERE '.$where_clause;
1436
+			if ($where_clause != '') {
1437
+						$sql .= ' WHERE '.$where_clause;
1438
+			}
1437 1439
 
1438 1440
 			// Now, let's perform the request:
1439 1441
 			$result = $this->dbConnection->getOne($sql, array());
@@ -1444,8 +1446,9 @@  discard block
 block discarded – undo
1444 1446
 		$sql = "SELECT DISTINCT ".$this->dbConnection->escapeDBItem($table_name).".* $orderby_column_statement FROM $sql";
1445 1447
 
1446 1448
 		$where_clause = $filter->toSql($this->dbConnection);
1447
-		if ($where_clause != '')
1448
-		$sql .= ' WHERE '.$where_clause;
1449
+		if ($where_clause != '') {
1450
+				$sql .= ' WHERE '.$where_clause;
1451
+		}
1449 1452
 
1450 1453
 		$sql .= $orderby_statement;
1451 1454
 
@@ -1470,8 +1473,7 @@  discard block
 block discarded – undo
1470 1473
 			$filter_bag = array();
1471 1474
 		} elseif (!is_array($filter_bag)) {
1472 1475
 			$filter_bag = array($filter_bag);
1473
-		}
1474
-		elseif (is_a($filter_bag, 'Mouf\\Database\\TDBM\\TDBMObjectArray')) {
1476
+		} elseif (is_a($filter_bag, 'Mouf\\Database\\TDBM\\TDBMObjectArray')) {
1475 1477
 			$filter_bag = array($filter_bag);
1476 1478
 		}
1477 1479
 
@@ -1553,8 +1555,9 @@  discard block
 block discarded – undo
1553 1555
 		// Fourth, let's apply the same steps to the orderby_bag
1554 1556
 		// 4-1 orderby_bag should be an array, if it is a singleton, let's put it in an array.
1555 1557
 
1556
-		if (!is_array($orderby_bag))
1557
-		$orderby_bag = array($orderby_bag);
1558
+		if (!is_array($orderby_bag)) {
1559
+				$orderby_bag = array($orderby_bag);
1560
+		}
1558 1561
 
1559 1562
 		// 4-2, let's take all the objects out of the orderby bag, and let's make objects from them
1560 1563
 		$orderby_bag2 = array();
@@ -1583,10 +1586,11 @@  discard block
 block discarded – undo
1583 1586
 			$possible_tables = $this->dbConnection->checkTableExist($table);
1584 1587
 			if ($possible_tables !== true)
1585 1588
 			{
1586
-				if (count($possible_tables)==1)
1587
-				$str = "Could not find table '$table'. Maybe you meant this table: '".$possible_tables[0]."'";
1588
-				else
1589
-				$str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$possible_tables)."'";
1589
+				if (count($possible_tables)==1) {
1590
+								$str = "Could not find table '$table'. Maybe you meant this table: '".$possible_tables[0]."'";
1591
+				} else {
1592
+								$str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$possible_tables)."'";
1593
+				}
1590 1594
 				throw new TDBMException($str);
1591 1595
 			}
1592 1596
 		}
@@ -1626,16 +1630,15 @@  discard block
 block discarded – undo
1626 1630
 							$link['col2']==$child->keyParent &&
1627 1631
 							$link['type']==$child->link_type) {
1628 1632
 								$current_node = $child;
1629
-							}
1630
-							else
1633
+							} else
1631 1634
 							{
1632 1635
 								// Now, we must add the rest of the links to the tree.
1633 1636
 								$found = false;
1634 1637
 							}
1635 1638
 						}
1639
+					} else {
1640
+										$found = false;
1636 1641
 					}
1637
-					else
1638
-					$found = false;
1639 1642
 
1640 1643
 				}
1641 1644
 
@@ -1706,13 +1709,14 @@  discard block
 block discarded – undo
1706 1709
 				// Unable to find primary key.... this is an error
1707 1710
 				// Let's try to be precise in error reporting. Let's try to find the table.
1708 1711
 				$tables = $this->dbConnection->checkTableExist($table);
1709
-				if ($tables === true)
1710
-				throw new TDBMException("Could not find table primary key for table '$table'. Please define a primary key for this table.");
1711
-				elseif ($tables !== null) {
1712
-					if (count($tables)==1)
1713
-					$str = "Could not find table '$table'. Maybe you meant this table: '".$tables[0]."'";
1714
-					else
1715
-					$str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$tables)."'";
1712
+				if ($tables === true) {
1713
+								throw new TDBMException("Could not find table primary key for table '$table'. Please define a primary key for this table.");
1714
+				} elseif ($tables !== null) {
1715
+					if (count($tables)==1) {
1716
+										$str = "Could not find table '$table'. Maybe you meant this table: '".$tables[0]."'";
1717
+					} else {
1718
+										$str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$tables)."'";
1719
+					}
1716 1720
 					throw new TDBMException($str);
1717 1721
 				}
1718 1722
 			}
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/OrderBySQLString.php 1 patch
Braces   +19 added lines, -14 removed lines patch added patch discarded remove patch
@@ -89,8 +89,9 @@  discard block
 block discarded – undo
89 89
 			while (true) {
90 90
 				$result = strrpos($phrase, "'", $result+1);
91 91
 				if ($result===false) {
92
-					if ($sentence!='')
93
-					$sentence .= ',';
92
+					if ($sentence!='') {
93
+										$sentence .= ',';
94
+					}
94 95
 					$sentence .= $phrase;
95 96
 
96 97
 					if ($is_inside_quotes) {
@@ -100,16 +101,16 @@  discard block
 block discarded – undo
100 101
 						$sentence = '';
101 102
 						break;
102 103
 					}
103
-				}
104
-				else
104
+				} else
105 105
 				{
106 106
 					$valid_result = true;
107 107
 					//echo '-'.$phrase{$result-1}.'-';
108 108
 					if ($result>0 && $phrase{$result-1}=='\\') {
109 109
 						$valid_result = false;
110 110
 					}
111
-					if ($valid_result)
112
-					$is_inside_quotes = !$is_inside_quotes;
111
+					if ($valid_result) {
112
+										$is_inside_quotes = !$is_inside_quotes;
113
+					}
113 114
 				}
114 115
 			}
115 116
 
@@ -137,23 +138,27 @@  discard block
 block discarded – undo
137 138
 		// Now, let's split the string using '
138 139
 		$work_table = explode("'", $work_str);
139 140
 
140
-		if (count($work_table)==0)
141
-		return '';
141
+		if (count($work_table)==0) {
142
+				return '';
143
+		}
142 144
 
143 145
 		// if we start with a ', let's remove the first text
144
-		if (strstr($work_str,"'")===0)
145
-		array_shift($work_table);
146
+		if (strstr($work_str,"'")===0) {
147
+				array_shift($work_table);
148
+		}
146 149
 			
147
-		if (count($work_table)==0)
148
-		return '';
150
+		if (count($work_table)==0) {
151
+				return '';
152
+		}
149 153
 
150 154
 		// Now, let's take only the stuff outside the quotes.
151 155
 		$work_str2 = '';
152 156
 
153 157
 		$i=0;
154 158
 		foreach ($work_table as $str_fragment) {
155
-			if (($i % 2) == 0)
156
-			$work_str2 .= $str_fragment.' ';
159
+			if (($i % 2) == 0) {
160
+						$work_str2 .= $str_fragment.' ';
161
+			}
157 162
 			$i++;
158 163
 		}
159 164
 
Please login to merge, or discard this patch.