@@ -85,7 +85,7 @@ |
||
85 | 85 | * @param string $columnName |
86 | 86 | * @param string $value |
87 | 87 | */ |
88 | - public function __construct($tableName=null, $columnName=null, $value=null) { |
|
88 | + public function __construct($tableName = null, $columnName = null, $value = null) { |
|
89 | 89 | $this->tableName = $tableName; |
90 | 90 | $this->columnName = $columnName; |
91 | 91 | $this->value = $value; |
@@ -85,7 +85,7 @@ |
||
85 | 85 | * @param string $columnName |
86 | 86 | * @param string $value |
87 | 87 | */ |
88 | - public function __construct($tableName=null, $columnName=null, $value=null) { |
|
88 | + public function __construct($tableName = null, $columnName = null, $value = null) { |
|
89 | 89 | $this->tableName = $tableName; |
90 | 90 | $this->columnName = $columnName; |
91 | 91 | $this->value = $value; |
@@ -85,7 +85,7 @@ |
||
85 | 85 | * @param string $columnName |
86 | 86 | * @param string $value |
87 | 87 | */ |
88 | - public function __construct($tableName=null, $columnName=null, $value=null) { |
|
88 | + public function __construct($tableName = null, $columnName = null, $value = null) { |
|
89 | 89 | $this->tableName = $tableName; |
90 | 90 | $this->columnName = $columnName; |
91 | 91 | $this->value = $value; |
@@ -85,7 +85,7 @@ |
||
85 | 85 | * @param string $columnName |
86 | 86 | * @param string $value |
87 | 87 | */ |
88 | - public function __construct($tableName=null, $columnName=null, $value=null) { |
|
88 | + public function __construct($tableName = null, $columnName = null, $value = null) { |
|
89 | 89 | $this->tableName = $tableName; |
90 | 90 | $this->columnName = $columnName; |
91 | 91 | $this->value = $value; |
@@ -148,7 +148,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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); |
@@ -1466,7 +1466,7 @@ discard block |
||
1466 | 1466 | } |
1467 | 1467 | |
1468 | 1468 | //If no $hint_path is provided, check that a path exists |
1469 | - if($hint_path === null){ |
|
1469 | + if ($hint_path === null) { |
|
1470 | 1470 | // Now, for each needed table to perform the order by, we must verify if the relationship between the order by and the object is indeed a 1* relationship |
1471 | 1471 | foreach ($needed_table_array_for_orderby as $target_table_table) { |
1472 | 1472 | // Get the path between the main table and the target group by table |
@@ -1482,7 +1482,7 @@ discard block |
||
1482 | 1482 | */ |
1483 | 1483 | $is_ok = true; |
1484 | 1484 | foreach ($path as $step) { |
1485 | - if ($step["type"]=="1*") { |
|
1485 | + if ($step["type"] == "1*") { |
|
1486 | 1486 | $is_ok = false; |
1487 | 1487 | break; |
1488 | 1488 | } |
@@ -1508,7 +1508,7 @@ discard block |
||
1508 | 1508 | $orderby_columns_array = array_merge($orderby_columns_array, $orderby_object->toSqlStatementsArray()); |
1509 | 1509 | } |
1510 | 1510 | |
1511 | - $orderby_statement = ' ORDER BY '.implode(',',$orderby_columns_array); |
|
1511 | + $orderby_statement = ' ORDER BY '.implode(',', $orderby_columns_array); |
|
1512 | 1512 | $count = 0; |
1513 | 1513 | foreach ($orderby_columns_array as $id=>$orderby_statement_phrase) { |
1514 | 1514 | // Let's remove the trailing ASC or DESC and add AS tdbm_reserved_col_Xxx |
@@ -1526,10 +1526,10 @@ discard block |
||
1526 | 1526 | $orderby_columns_array[$id] = $orderby_statement_phrase.' AS tdbm_reserved_col_'.$count; |
1527 | 1527 | $count++; |
1528 | 1528 | } |
1529 | - $orderby_column_statement = ', '.implode(',',$orderby_columns_array); |
|
1529 | + $orderby_column_statement = ', '.implode(',', $orderby_columns_array); |
|
1530 | 1530 | } |
1531 | 1531 | |
1532 | - if ($mode=="getCount") { |
|
1532 | + if ($mode == "getCount") { |
|
1533 | 1533 | // Let's get the list of primary keys to perform a DISTINCT request. |
1534 | 1534 | $pk_table = $this->getPrimaryKeyStatic($table_name); |
1535 | 1535 | |
@@ -1563,7 +1563,7 @@ discard block |
||
1563 | 1563 | if ($mode == 'explainSQL') { |
1564 | 1564 | return $sql; |
1565 | 1565 | } |
1566 | - return $this->getObjectsFromSQL($table_name, $sql, $from, $limit, $className); |
|
1566 | + return $this->getObjectsFromSQL($table_name, $sql, $from, $limit, $className); |
|
1567 | 1567 | |
1568 | 1568 | } |
1569 | 1569 | |
@@ -1588,17 +1588,17 @@ discard block |
||
1588 | 1588 | // Second, let's take all the objects out of the filter bag, and let's make filters from them |
1589 | 1589 | $filter_bag2 = array(); |
1590 | 1590 | foreach ($filter_bag as $thing) { |
1591 | - if (is_a($thing,'Mouf\\Database\\TDBM\\Filters\\FilterInterface')) { |
|
1591 | + if (is_a($thing, 'Mouf\\Database\\TDBM\\Filters\\FilterInterface')) { |
|
1592 | 1592 | $filter_bag2[] = $thing; |
1593 | 1593 | } elseif (is_string($thing)) { |
1594 | 1594 | $filter_bag2[] = new SqlStringFilter($thing); |
1595 | - } elseif (is_a($thing,'Mouf\\Database\\TDBM\\TDBMObjectArray') && count($thing)>0) { |
|
1595 | + } elseif (is_a($thing, 'Mouf\\Database\\TDBM\\TDBMObjectArray') && count($thing)>0) { |
|
1596 | 1596 | // Get table_name and column_name |
1597 | 1597 | $filter_table_name = $thing[0]->_getDbTableName(); |
1598 | 1598 | $filter_column_names = $thing[0]->getPrimaryKey(); |
1599 | 1599 | |
1600 | 1600 | // If there is only one primary key, we can use the InFilter |
1601 | - if (count($filter_column_names)==1) { |
|
1601 | + if (count($filter_column_names) == 1) { |
|
1602 | 1602 | $primary_keys_array = array(); |
1603 | 1603 | $filter_column_name = $filter_column_names[0]; |
1604 | 1604 | foreach ($thing as $TDBMObject) { |
@@ -1611,7 +1611,7 @@ discard block |
||
1611 | 1611 | { |
1612 | 1612 | $filter_bag_and = array(); |
1613 | 1613 | foreach ($thing as $TDBMObject) { |
1614 | - $filter_bag_temp_and=array(); |
|
1614 | + $filter_bag_temp_and = array(); |
|
1615 | 1615 | foreach ($filter_column_names as $pk) { |
1616 | 1616 | $filter_bag_temp_and[] = new EqualFilter($TDBMObject->_getDbTableName(), $pk, $TDBMObject->$pk); |
1617 | 1617 | } |
@@ -1621,7 +1621,7 @@ discard block |
||
1621 | 1621 | } |
1622 | 1622 | |
1623 | 1623 | |
1624 | - } elseif (!is_a($thing,'Mouf\\Database\\TDBM\\TDBMObjectArray') && $thing!==null) { |
|
1624 | + } elseif (!is_a($thing, 'Mouf\\Database\\TDBM\\TDBMObjectArray') && $thing !== null) { |
|
1625 | 1625 | 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."); |
1626 | 1626 | } |
1627 | 1627 | } |
@@ -1649,9 +1649,9 @@ discard block |
||
1649 | 1649 | // 4-2, let's take all the objects out of the orderby bag, and let's make objects from them |
1650 | 1650 | $orderby_bag2 = array(); |
1651 | 1651 | foreach ($orderby_bag as $thing) { |
1652 | - if (is_a($thing,'Mouf\\Database\\TDBM\\Filters\\OrderBySQLString')) { |
|
1652 | + if (is_a($thing, 'Mouf\\Database\\TDBM\\Filters\\OrderBySQLString')) { |
|
1653 | 1653 | $orderby_bag2[] = $thing; |
1654 | - } elseif (is_a($thing,'Mouf\\Database\\TDBM\\Filters\\OrderByColumn')) { |
|
1654 | + } elseif (is_a($thing, 'Mouf\\Database\\TDBM\\Filters\\OrderByColumn')) { |
|
1655 | 1655 | $orderby_bag2[] = $thing; |
1656 | 1656 | } elseif (is_string($thing)) { |
1657 | 1657 | $orderby_bag2[] = new OrderBySQLString($thing); |
@@ -1674,10 +1674,10 @@ discard block |
||
1674 | 1674 | $possible_tables = $this->dbConnection->checkTableExist($table); |
1675 | 1675 | if ($possible_tables !== true) |
1676 | 1676 | { |
1677 | - if (count($possible_tables)==1) |
|
1677 | + if (count($possible_tables) == 1) |
|
1678 | 1678 | $str = "Could not find table '$table'. Maybe you meant this table: '".$possible_tables[0]."'"; |
1679 | 1679 | else |
1680 | - $str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$possible_tables)."'"; |
|
1680 | + $str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '", $possible_tables)."'"; |
|
1681 | 1681 | throw new TDBMException($str); |
1682 | 1682 | } |
1683 | 1683 | } |
@@ -1700,16 +1700,16 @@ discard block |
||
1700 | 1700 | $current_node = $tree; |
1701 | 1701 | $found = true; |
1702 | 1702 | foreach ($path as $link) { |
1703 | - if ($found==true) |
|
1703 | + if ($found == true) |
|
1704 | 1704 | { |
1705 | 1705 | if (is_array($current_node->getChildren())) |
1706 | 1706 | { |
1707 | 1707 | foreach ($current_node->getChildren() as $child) |
1708 | 1708 | { |
1709 | - if ($link['table1']==$child->table_name && |
|
1710 | - $link['col1']==$child->keyNode && |
|
1711 | - $link['col2']==$child->keyParent && |
|
1712 | - $link['type']==$child->link_type) { |
|
1709 | + if ($link['table1'] == $child->table_name && |
|
1710 | + $link['col1'] == $child->keyNode && |
|
1711 | + $link['col2'] == $child->keyParent && |
|
1712 | + $link['type'] == $child->link_type) { |
|
1713 | 1713 | $current_node = $child; |
1714 | 1714 | } |
1715 | 1715 | else |
@@ -1724,7 +1724,7 @@ discard block |
||
1724 | 1724 | |
1725 | 1725 | } |
1726 | 1726 | |
1727 | - if ($found==false) |
|
1727 | + if ($found == false) |
|
1728 | 1728 | { |
1729 | 1729 | $current_node = new DisplayNode($link['table1'], $current_node, $link['type'], $link['col2'], $link['col1']); |
1730 | 1730 | } |
@@ -1749,7 +1749,7 @@ discard block |
||
1749 | 1749 | * |
1750 | 1750 | * @return string |
1751 | 1751 | */ |
1752 | - public function drawTree($tree, $x, $y, &$ret_width=0, &$ret_height=0) { |
|
1752 | + public function drawTree($tree, $x, $y, &$ret_width = 0, &$ret_height = 0) { |
|
1753 | 1753 | |
1754 | 1754 | // Let's get the background div: |
1755 | 1755 | $treeDepth = $tree->computeDepth(1)-1; |
@@ -1760,7 +1760,7 @@ discard block |
||
1760 | 1760 | |
1761 | 1761 | $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>"; |
1762 | 1762 | |
1763 | - $str .= $tree->draw(0,0, $x, $y); |
|
1763 | + $str .= $tree->draw(0, 0, $x, $y); |
|
1764 | 1764 | |
1765 | 1765 | return $str; |
1766 | 1766 | } |
@@ -1795,10 +1795,10 @@ discard block |
||
1795 | 1795 | if ($tables === true) |
1796 | 1796 | throw new TDBMException("Could not find table primary key for table '$table'. Please define a primary key for this table."); |
1797 | 1797 | elseif ($tables !== null) { |
1798 | - if (count($tables)==1) |
|
1798 | + if (count($tables) == 1) |
|
1799 | 1799 | $str = "Could not find table '$table'. Maybe you meant this table: '".$tables[0]."'"; |
1800 | 1800 | else |
1801 | - $str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$tables)."'"; |
|
1801 | + $str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '", $tables)."'"; |
|
1802 | 1802 | throw new TDBMException($str); |
1803 | 1803 | } |
1804 | 1804 | } |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | $pos = strpos($str, ' '); |
864 | 864 | } |
865 | 865 | $before = substr($str, 0, $pos); |
866 | - $after = substr($str, $pos + 1); |
|
866 | + $after = substr($str, $pos+1); |
|
867 | 867 | $str = $before.strtoupper(substr($after, 0, 1)).substr($after, 1); |
868 | 868 | } |
869 | 869 | |
@@ -881,14 +881,14 @@ discard block |
||
881 | 881 | public static function toSingular($str) |
882 | 882 | { |
883 | 883 | // First, ignore "ss" words (like access). |
884 | - if (strpos($str, 'ss', strlen($str) - 2) !== false) { |
|
884 | + if (strpos($str, 'ss', strlen($str)-2) !== false) { |
|
885 | 885 | return $str; |
886 | 886 | } |
887 | 887 | |
888 | 888 | // Now, let's see if the string ends with s: |
889 | - if (strpos($str, 's', strlen($str) - 1) !== false) { |
|
889 | + if (strpos($str, 's', strlen($str)-1) !== false) { |
|
890 | 890 | // Yes? Let's remove the s. |
891 | - return substr($str, 0, strlen($str) - 1); |
|
891 | + return substr($str, 0, strlen($str)-1); |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | return $str; |