@@ -136,8 +136,7 @@ discard block |
||
136 | 136 | * This action generates the TDBM instance, then the DAOs and Beans. |
137 | 137 | * |
138 | 138 | * @Action |
139 | - * @param string $name |
|
140 | - * @param bool $selfedit |
|
139 | + * @param string|boolean $selfedit |
|
141 | 140 | */ |
142 | 141 | public function generate($sourcedirectory, $daonamespace, $beannamespace, $keepSupport = 0, $storeInUtc = 0, $selfedit="false") { |
143 | 142 | $this->selfedit = $selfedit; |
@@ -163,6 +162,9 @@ discard block |
||
163 | 162 | |
164 | 163 | protected $errorMsg; |
165 | 164 | |
165 | + /** |
|
166 | + * @param string $msg |
|
167 | + */ |
|
166 | 168 | private function displayErrorMsg($msg) { |
167 | 169 | $this->errorMsg = $msg; |
168 | 170 | $this->content->addFile(dirname(__FILE__)."/../../../../views/installError.php", $this); |
@@ -2,11 +2,8 @@ |
||
2 | 2 | namespace Mouf\Database\TDBM\Controllers; |
3 | 3 | |
4 | 4 | use Mouf\MoufUtils; |
5 | - |
|
6 | 5 | use Mouf\Actions\InstallUtils; |
7 | - |
|
8 | 6 | use Mouf\MoufManager; |
9 | - |
|
10 | 7 | use Mouf\Html\HtmlElement\HtmlBlock; |
11 | 8 | use Mouf\Mvc\Splash\Controllers\Controller; |
12 | 9 |
@@ -139,7 +139,7 @@ |
||
139 | 139 | * @param string $name |
140 | 140 | * @param bool $selfedit |
141 | 141 | */ |
142 | - public function generate($sourcedirectory, $daonamespace, $beannamespace, $keepSupport = 0, $storeInUtc = 0, $selfedit="false") { |
|
142 | + public function generate($sourcedirectory, $daonamespace, $beannamespace, $keepSupport = 0, $storeInUtc = 0, $selfedit = "false") { |
|
143 | 143 | $this->selfedit = $selfedit; |
144 | 144 | |
145 | 145 | if ($selfedit == "true") { |
@@ -48,7 +48,7 @@ |
||
48 | 48 | * Default constructor to build the filter. |
49 | 49 | * All parameters are optional and can later be set using the setters. |
50 | 50 | * |
51 | - * @param array<FilterInterface> $filter |
|
51 | + * @param array<FilterInterface> $filters |
|
52 | 52 | */ |
53 | 53 | public function __construct($filters=null) { |
54 | 54 | $this->filters = $filters; |
@@ -2,7 +2,6 @@ |
||
2 | 2 | namespace Mouf\Database\TDBM\Filters; |
3 | 3 | |
4 | 4 | use Mouf\Database\TDBM\TDBMException; |
5 | - |
|
6 | 5 | use Mouf\Database\DBConnection\ConnectionInterface; |
7 | 6 | |
8 | 7 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @param array<FilterInterface> $filter |
52 | 52 | */ |
53 | - public function __construct($filters=null) { |
|
53 | + public function __construct($filters = null) { |
|
54 | 54 | $this->filters = $filters; |
55 | 55 | } |
56 | 56 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | if (count($filters_sql)>0) { |
95 | - return '('.implode(' AND ',$filters_sql).')'; |
|
95 | + return '('.implode(' AND ', $filters_sql).')'; |
|
96 | 96 | } else { |
97 | 97 | return ''; |
98 | 98 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | throw new TDBMException("Error in AndFilter: One of the parameters is not a filter."); |
116 | 116 | } |
117 | 117 | |
118 | - $tables = array_merge($tables,$filter->getUsedTables()); |
|
118 | + $tables = array_merge($tables, $filter->getUsedTables()); |
|
119 | 119 | } |
120 | 120 | // Remove tables in double. |
121 | 121 | $tables = array_flip(array_flip($tables)); |
@@ -57,7 +57,7 @@ |
||
57 | 57 | * Default constructor to build the filter. |
58 | 58 | * All parameters are optional and can later be set using the setters. |
59 | 59 | * |
60 | - * @param array<FilterInterface> $filter |
|
60 | + * @param array<FilterInterface> $filters |
|
61 | 61 | */ |
62 | 62 | public function __construct($filters=null) { |
63 | 63 | $this->filters = $filters; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @param array<FilterInterface> $filter |
61 | 61 | */ |
62 | - public function __construct($filters=null) { |
|
62 | + public function __construct($filters = null) { |
|
63 | 63 | $this->filters = $filters; |
64 | 64 | } |
65 | 65 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | if (count($filters_sql)>0) { |
93 | - return '('.implode(' OR ',$filters_sql).')'; |
|
93 | + return '('.implode(' OR ', $filters_sql).')'; |
|
94 | 94 | } else { |
95 | 95 | return ''; |
96 | 96 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | $tables = array(); |
109 | 109 | foreach ($this->filters as $filter) { |
110 | - $tables = array_merge($tables,$filter->getUsedTables()); |
|
110 | + $tables = array_merge($tables, $filter->getUsedTables()); |
|
111 | 111 | } |
112 | 112 | // Remove tables in double. |
113 | 113 | $tables = array_flip(array_flip($tables)); |
@@ -962,7 +962,7 @@ discard block |
||
962 | 962 | * @param unknown_type $target_tables |
963 | 963 | * @param unknown_type $path |
964 | 964 | * @param unknown_type $queue |
965 | - * @return unknown |
|
965 | + * @return boolean |
|
966 | 966 | */ |
967 | 967 | private function find_paths_iter(&$target_tables, &$path, &$queue) { |
968 | 968 | // Get table to look at: |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | * @param unknown_type $table_name The name of the table queried |
1185 | 1185 | * @param unknown_type $filter_bag The filter bag (see getObjects for complete description) |
1186 | 1186 | * @param unknown_type $hint_path |
1187 | - * @return integer |
|
1187 | + * @return TDBMObjectArray |
|
1188 | 1188 | */ |
1189 | 1189 | public function getCount($table_name, $filter_bag=null, $hint_path=null) { |
1190 | 1190 | if ($this->dbConnection == null) { |
@@ -1202,7 +1202,7 @@ discard block |
||
1202 | 1202 | * @param integer $from The offset |
1203 | 1203 | * @param integer $limit The maximum number of rows returned |
1204 | 1204 | * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null). |
1205 | - * @return string The SQL that would be executed. |
|
1205 | + * @return TDBMObjectArray The SQL that would be executed. |
|
1206 | 1206 | */ |
1207 | 1207 | public function explainSQLGetObjects($table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $hint_path=null) { |
1208 | 1208 | if ($this->dbConnection == null) { |
@@ -1461,7 +1461,7 @@ discard block |
||
1461 | 1461 | * Takes in input a filter_bag (which can be about anything from a string to an array of TDBMObjects... see above from documentation), |
1462 | 1462 | * and gives back a proper Filter object. |
1463 | 1463 | * |
1464 | - * @param unknown_type $filter_bag |
|
1464 | + * @param unknown_type|null $filter_bag |
|
1465 | 1465 | * @return FilterInterface |
1466 | 1466 | */ |
1467 | 1467 | public function buildFilterFromFilterBag($filter_bag) { |
@@ -1546,7 +1546,7 @@ discard block |
||
1546 | 1546 | * Takes in input an order_bag (which can be about anything from a string to an array of OrderByColumn objects... see above from documentation), |
1547 | 1547 | * and gives back an array of OrderByColumn / OrderBySQLString objects. |
1548 | 1548 | * |
1549 | - * @param unknown_type $orderby_bag |
|
1549 | + * @param unknown_type|null $orderby_bag |
|
1550 | 1550 | * @return array |
1551 | 1551 | */ |
1552 | 1552 | public function buildOrderArrayFromOrderBag($orderby_bag) { |
@@ -1661,6 +1661,8 @@ discard block |
||
1661 | 1661 | * This function returns the HTML to draw a tree of DisplayNode. |
1662 | 1662 | * |
1663 | 1663 | * @param unknown_type $tree |
1664 | + * @param integer $x |
|
1665 | + * @param integer $y |
|
1664 | 1666 | */ |
1665 | 1667 | public function drawTree($tree, $x, $y, &$ret_width=0, &$ret_height=0) { |
1666 | 1668 |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | private $cacheKey = "__TDBM_Cache__"; |
124 | 124 | |
125 | 125 | public function __construct() { |
126 | - register_shutdown_function(array($this,"completeSaveOnExit")); |
|
126 | + register_shutdown_function(array($this, "completeSaveOnExit")); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | $objects = $this->getObjects($table_name, $filters, null, null, null, $className); |
327 | 327 | if (count($objects) == 0) { |
328 | 328 | return null; |
329 | - } elseif (count($objects) > 1) { |
|
329 | + } elseif (count($objects)>1) { |
|
330 | 330 | 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."); |
331 | 331 | } |
332 | 332 | // Return the first and only object. |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | } |
351 | 351 | |
352 | 352 | if (isset($this->objects[$table_name][$id])) { |
353 | - $obj = $this->objects[$table_name][$id]; |
|
353 | + $obj = $this->objects[$table_name][$id]; |
|
354 | 354 | if ($className == null || is_a($obj, $className)) { |
355 | 355 | return $obj; |
356 | 356 | } else { |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | * @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. |
396 | 396 | * @return TDBMObject |
397 | 397 | */ |
398 | - public function getNewObject($table_name, $auto_assign_id=true, $className = null) { |
|
398 | + public function getNewObject($table_name, $auto_assign_id = true, $className = null) { |
|
399 | 399 | if ($this->dbConnection == null) { |
400 | 400 | throw new TDBMException("Error while calling TDBMObject::getNewObject(): No connection has been established on the database!"); |
401 | 401 | } |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | } |
426 | 426 | |
427 | 427 | if ($auto_assign_id && !$this->isPrimaryKeyAutoIncrement($table_name)) { |
428 | - $pk_table = $this->getPrimaryKeyStatic($table_name); |
|
429 | - if (count($pk_table)==1) |
|
428 | + $pk_table = $this->getPrimaryKeyStatic($table_name); |
|
429 | + if (count($pk_table) == 1) |
|
430 | 430 | { |
431 | 431 | $root_table = $this->dbConnection->findRootSequenceTable($table_name); |
432 | 432 | $id = $this->dbConnection->nextId($root_table); |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | $sql = "SELECT MAX(".$this->dbConnection->escapeDBItem($pk_table[0]).") AS maxkey FROM ".$root_table; |
437 | 437 | $res = $this->dbConnection->getAll($sql); |
438 | 438 | // NOTE: this will work only if the ID is an integer! |
439 | - $newid = $res[0]['maxkey'] + 1; |
|
439 | + $newid = $res[0]['maxkey']+1; |
|
440 | 440 | if ($newid>$id) { |
441 | 441 | $id = $newid; |
442 | 442 | } |
@@ -467,17 +467,17 @@ discard block |
||
467 | 467 | // Now for the object_id |
468 | 468 | $object_id = $object->TDBMObject_id; |
469 | 469 | // If there is only one primary key: |
470 | - if (count($pk_table)==1) { |
|
470 | + if (count($pk_table) == 1) { |
|
471 | 471 | $sql_where = $this->dbConnection->escapeDBItem($pk_table[0])."=".$this->dbConnection->quoteSmart($object->TDBMObject_id); |
472 | 472 | } else { |
473 | 473 | $ids = unserialize($object_id); |
474 | - $i=0; |
|
474 | + $i = 0; |
|
475 | 475 | $sql_where_array = array(); |
476 | 476 | foreach ($pk_table as $pk) { |
477 | 477 | $sql_where_array[] = $this->dbConnection->escapeDBItem($pk)."=".$this->dbConnection->quoteSmart($ids[$i]); |
478 | 478 | $i++; |
479 | 479 | } |
480 | - $sql_where = implode(" AND ",$sql_where_array); |
|
480 | + $sql_where = implode(" AND ", $sql_where_array); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * @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. |
521 | 521 | * @return TDBMObjectArray The result set of the query as a TDBMObjectArray (an array of TDBMObjects with special properties) |
522 | 522 | */ |
523 | - public function getObjectsFromSQL($table_name, $sql, $from=null, $limit=null, $className=null) { |
|
523 | + public function getObjectsFromSQL($table_name, $sql, $from = null, $limit = null, $className = null) { |
|
524 | 524 | if ($this->dbConnection == null) { |
525 | 525 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
526 | 526 | } |
@@ -540,17 +540,17 @@ discard block |
||
540 | 540 | |
541 | 541 | if ($firstLine) { |
542 | 542 | // $keysStandardCased is an optimization to avoid calling toStandardCaseColumn on every cell of every row. |
543 | - foreach ($fullCaseRow as $key=>$value) { |
|
543 | + foreach ($fullCaseRow as $key=>$value) { |
|
544 | 544 | $keysStandardCased[$key] = $this->dbConnection->toStandardCaseColumn($key); |
545 | 545 | } |
546 | 546 | $firstLine = false; |
547 | 547 | } |
548 | - foreach ($fullCaseRow as $key=>$value) { |
|
549 | - $row[$keysStandardCased[$key]]=$value; |
|
548 | + foreach ($fullCaseRow as $key=>$value) { |
|
549 | + $row[$keysStandardCased[$key]] = $value; |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | $pk_table = $this->primary_keys[$table_name]; |
553 | - if (count($pk_table)==1) |
|
553 | + if (count($pk_table) == 1) |
|
554 | 554 | { |
555 | 555 | if (!isset($keysStandardCased[$pk_table[0]])) { |
556 | 556 | 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); |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | $this->objects[$table_name][$id]->loadFromRow($row); |
586 | 586 | // Check that the object fetched from cache is from the requested class. |
587 | 587 | if ($className != null) { |
588 | - if (!is_subclass_of(get_class($this->objects[$table_name][$id]), $className) && get_class($this->objects[$table_name][$id]) != $className) { |
|
588 | + if (!is_subclass_of(get_class($this->objects[$table_name][$id]), $className) && get_class($this->objects[$table_name][$id]) != $className) { |
|
589 | 589 | throw new TDBMException("Error while calling TDBM: An object fetched from database is already present in TDBM cache and they do not share the same class. You requested the object to be of the class ".$className." but the object available locally is of the class ".get_class($this->objects[$table_name][$id])."."); |
590 | 590 | } |
591 | 591 | } |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | // Check that the object fetched from cache is from the requested class. |
594 | 594 | if ($className != null) { |
595 | 595 | $className = ltrim($className, '\\'); |
596 | - if (!is_subclass_of(get_class($this->objects[$table_name][$id]), $className) && get_class($this->objects[$table_name][$id]) != $className) { |
|
596 | + if (!is_subclass_of(get_class($this->objects[$table_name][$id]), $className) && get_class($this->objects[$table_name][$id]) != $className) { |
|
597 | 597 | throw new TDBMException("Error while calling TDBM: An object fetched from database is already present in TDBM cache and they do not share the same class. You requested the object to be of the class ".$className." but the object available locally is of the class ".get_class($this->objects[$table_name][$id])."."); |
598 | 598 | } |
599 | 599 | } |
@@ -676,14 +676,14 @@ discard block |
||
676 | 676 | // Now, let's commit or rollback if needed. |
677 | 677 | if ($this->dbConnection != null && $this->dbConnection->hasActiveTransaction()) { |
678 | 678 | if ($this->commitOnQuit) { |
679 | - try { |
|
679 | + try { |
|
680 | 680 | $this->dbConnection->commit(); |
681 | 681 | } catch (Exception $e) { |
682 | 682 | echo $e->getMessage()."<br/>"; |
683 | 683 | echo $e->getTraceAsString(); |
684 | 684 | } |
685 | 685 | } else { |
686 | - try { |
|
686 | + try { |
|
687 | 687 | $this->dbConnection->rollback(); |
688 | 688 | } catch (Exception $e) { |
689 | 689 | echo $e->getMessage()."<br/>"; |
@@ -754,21 +754,21 @@ discard block |
||
754 | 754 | * @param string $sql |
755 | 755 | * @return array the result of your query |
756 | 756 | */ |
757 | - public function getTransientObjectsFromSQL($sql,$classname=null) { |
|
757 | + public function getTransientObjectsFromSQL($sql, $classname = null) { |
|
758 | 758 | if ($this->dbConnection == null) { |
759 | 759 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
760 | 760 | } |
761 | - return $this->dbConnection->getAll($sql, \PDO::FETCH_CLASS,$classname); |
|
761 | + return $this->dbConnection->getAll($sql, \PDO::FETCH_CLASS, $classname); |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | |
765 | 765 | private function to_explain_string($path) { |
766 | 766 | $msg = ''; |
767 | 767 | foreach ($path as $constraint) { |
768 | - if ($constraint['type']=='1*') { |
|
768 | + if ($constraint['type'] == '1*') { |
|
769 | 769 | $msg .= 'Table "'.$constraint['table1'].'" points to "'.$constraint['table2'].'" through its foreign key "'.$constraint['col1'].'"\n'; |
770 | 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 | } |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | $this->loadCache(); |
788 | 788 | |
789 | 789 | $path = array(); |
790 | - $queue = array(array($table,array())); |
|
790 | + $queue = array(array($table, array())); |
|
791 | 791 | |
792 | 792 | //$found_paths=array(); |
793 | 793 | $found = false; |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | { |
824 | 824 | break; |
825 | 825 | } |
826 | - if ($ret==true) |
|
826 | + if ($ret == true) |
|
827 | 827 | { |
828 | 828 | |
829 | 829 | // Ok, we got one, we will continue a bit more until we reach the next level in the tree, |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | } |
835 | 835 | |
836 | 836 | // At each iteration, let's check the time. |
837 | - if ($this->trackExecutionTime && microtime(true)-self::$script_start_up_time > $max_execution_time && $max_execution_time!=0) { |
|
837 | + if ($this->trackExecutionTime && microtime(true)-self::$script_start_up_time>$max_execution_time && $max_execution_time != 0) { |
|
838 | 838 | // Call check table names |
839 | 839 | $this->checkTablesExist($tables); |
840 | 840 | |
@@ -845,11 +845,11 @@ discard block |
||
845 | 845 | } |
846 | 846 | } |
847 | 847 | |
848 | - $ambiguity =false; |
|
848 | + $ambiguity = false; |
|
849 | 849 | $msg = ''; |
850 | 850 | foreach ($tables_paths as $table_path) { |
851 | 851 | // If any table has not been found, throw an exception |
852 | - if (!isset($table_path['founddepth']) || $table_path['founddepth']==null) { |
|
852 | + if (!isset($table_path['founddepth']) || $table_path['founddepth'] == null) { |
|
853 | 853 | // First, check if the tables do exist. |
854 | 854 | $this->checkTablesExist(array($table, $table_path['name'])); |
855 | 855 | // Else, throw an error. |
@@ -914,7 +914,7 @@ discard block |
||
914 | 914 | 'table2' => $depArr['table1'], |
915 | 915 | 'col1' => $depArr['col2'], |
916 | 916 | 'col2' => $depArr['col1'], |
917 | - 'type' => (($depArr['type'] == '1*')?'*1':'1*') |
|
917 | + 'type' => (($depArr['type'] == '1*') ? '*1' : '1*') |
|
918 | 918 | ); |
919 | 919 | }, $toRevertPath); |
920 | 920 | return array_reverse($invertedDependencies); |
@@ -932,7 +932,7 @@ discard block |
||
932 | 932 | * @param unknown_type $paths |
933 | 933 | */ |
934 | 934 | private function flatten_paths($paths) { |
935 | - $flat_path=array(); |
|
935 | + $flat_path = array(); |
|
936 | 936 | foreach ($paths as $path_bigarray) { |
937 | 937 | $path = $path_bigarray['paths'][0]; |
938 | 938 | |
@@ -973,9 +973,9 @@ discard block |
||
973 | 973 | //echo '-'.$current_table.'-'; |
974 | 974 | //echo '.'; |
975 | 975 | foreach ($target_tables as $id=>$target_table) { |
976 | - if ($target_table['name'] == $current_table && (!isset($target_table['founddepth']) || $target_table['founddepth']==null || $target_table['founddepth']==count($path))) { |
|
976 | + if ($target_table['name'] == $current_table && (!isset($target_table['founddepth']) || $target_table['founddepth'] == null || $target_table['founddepth'] == count($path))) { |
|
977 | 977 | // When a path is found to a table, we mark the table as found with its depth. |
978 | - $target_tables[$id]['founddepth']=count($path); |
|
978 | + $target_tables[$id]['founddepth'] = count($path); |
|
979 | 979 | |
980 | 980 | // Then we add the path to table to the target_tables array |
981 | 981 | $target_tables[$id]['paths'][] = $path; |
@@ -1015,13 +1015,13 @@ discard block |
||
1015 | 1015 | $already_done = false; |
1016 | 1016 | foreach ($path as $previous_constraint) |
1017 | 1017 | { |
1018 | - if ($previous_constraint['type']=='1*' && $current_table == $previous_constraint["table2"] && $col2 == $previous_constraint["col2"] && $table1 == $previous_constraint["table1"] && $col1 == $previous_constraint["col1"]) |
|
1018 | + if ($previous_constraint['type'] == '1*' && $current_table == $previous_constraint["table2"] && $col2 == $previous_constraint["col2"] && $table1 == $previous_constraint["table1"] && $col1 == $previous_constraint["col1"]) |
|
1019 | 1019 | { |
1020 | 1020 | //echo "YOUHOU1! $current_table $col2"; |
1021 | 1021 | $already_done = true; |
1022 | 1022 | break; |
1023 | 1023 | } |
1024 | - elseif ($previous_constraint['type']=='*1' && $current_table == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"] && $table1 == $previous_constraint["table2"] && $col1 == $previous_constraint["col2"]) |
|
1024 | + elseif ($previous_constraint['type'] == '*1' && $current_table == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"] && $table1 == $previous_constraint["table2"] && $col1 == $previous_constraint["col2"]) |
|
1025 | 1025 | { |
1026 | 1026 | //echo "YOUHOU2! $current_table $col2"; |
1027 | 1027 | $already_done = true; |
@@ -1054,13 +1054,13 @@ discard block |
||
1054 | 1054 | foreach ($path as $previous_constraint) |
1055 | 1055 | { |
1056 | 1056 | //echo "TTTT".$table2." ".$col2."AAAA".$previous_constraint["table1"]." ".$previous_constraint["col1"]."YYYY".$previous_constraint["type"]."PPP"; |
1057 | - if ($previous_constraint['type']=='1*' && $table2 == $previous_constraint["table2"] && $col2 == $previous_constraint["col2"]) |
|
1057 | + if ($previous_constraint['type'] == '1*' && $table2 == $previous_constraint["table2"] && $col2 == $previous_constraint["col2"]) |
|
1058 | 1058 | { |
1059 | 1059 | //echo "YOUHOU3! $table2 $col2"; |
1060 | 1060 | $already_done = true; |
1061 | 1061 | break; |
1062 | 1062 | } |
1063 | - elseif ($previous_constraint['type']=='*1' && $table2 == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"]) |
|
1063 | + elseif ($previous_constraint['type'] == '*1' && $table2 == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"]) |
|
1064 | 1064 | { |
1065 | 1065 | //echo "YOUHOU4! $table2 $col2"; |
1066 | 1066 | $already_done = true; |
@@ -1170,7 +1170,7 @@ discard block |
||
1170 | 1170 | * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null). |
1171 | 1171 | * @return TDBMObjectArray A TDBMObjectArray containing the resulting objects of the query. |
1172 | 1172 | */ |
1173 | - public function getObjects($table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $className=null, $hint_path=null) { |
|
1173 | + public function getObjects($table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $className = null, $hint_path = null) { |
|
1174 | 1174 | if ($this->dbConnection == null) { |
1175 | 1175 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
1176 | 1176 | } |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | * @param unknown_type $hint_path |
1187 | 1187 | * @return integer |
1188 | 1188 | */ |
1189 | - public function getCount($table_name, $filter_bag=null, $hint_path=null) { |
|
1189 | + public function getCount($table_name, $filter_bag = null, $hint_path = null) { |
|
1190 | 1190 | if ($this->dbConnection == null) { |
1191 | 1191 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
1192 | 1192 | } |
@@ -1204,7 +1204,7 @@ discard block |
||
1204 | 1204 | * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null). |
1205 | 1205 | * @return string The SQL that would be executed. |
1206 | 1206 | */ |
1207 | - public function explainSQLGetObjects($table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $hint_path=null) { |
|
1207 | + public function explainSQLGetObjects($table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $hint_path = null) { |
|
1208 | 1208 | if ($this->dbConnection == null) { |
1209 | 1209 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
1210 | 1210 | } |
@@ -1222,7 +1222,7 @@ discard block |
||
1222 | 1222 | * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null). |
1223 | 1223 | * @return string The SQL that would be executed. |
1224 | 1224 | */ |
1225 | - public function explainRequestAsTextGetObjects($table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $hint_path=null) { |
|
1225 | + public function explainRequestAsTextGetObjects($table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $hint_path = null) { |
|
1226 | 1226 | if ($this->dbConnection == null) { |
1227 | 1227 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
1228 | 1228 | } |
@@ -1243,12 +1243,12 @@ discard block |
||
1243 | 1243 | * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null). |
1244 | 1244 | * @return string The SQL that would be executed. |
1245 | 1245 | */ |
1246 | - public function explainRequestAsHTMLGetObjects($table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $hint_path=null, $x=10, $y=10) { |
|
1246 | + public function explainRequestAsHTMLGetObjects($table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $hint_path = null, $x = 10, $y = 10) { |
|
1247 | 1247 | if ($this->dbConnection == null) { |
1248 | 1248 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
1249 | 1249 | } |
1250 | 1250 | $tree = $this->getObjectsByMode('explainTree', $table_name, $filter_bag, $orderby_bag, $from, $limit, $hint_path); |
1251 | - return $this->drawTree($tree,$x,$y); |
|
1251 | + return $this->drawTree($tree, $x, $y); |
|
1252 | 1252 | } |
1253 | 1253 | |
1254 | 1254 | /** |
@@ -1265,7 +1265,7 @@ discard block |
||
1265 | 1265 | * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null). |
1266 | 1266 | * @return TDBMObjectArray A TDBMObjectArray containing the resulting objects of the query. |
1267 | 1267 | */ |
1268 | - public function getObjectsByMode($mode, $table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $className=null, $hint_path=null) { |
|
1268 | + public function getObjectsByMode($mode, $table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $className = null, $hint_path = null) { |
|
1269 | 1269 | $this->completeSave(); |
1270 | 1270 | $this->loadCache(); |
1271 | 1271 | |
@@ -1304,7 +1304,7 @@ discard block |
||
1304 | 1304 | } |
1305 | 1305 | } |
1306 | 1306 | |
1307 | - if (count($needed_table_array)==0) |
|
1307 | + if (count($needed_table_array) == 0) |
|
1308 | 1308 | { |
1309 | 1309 | $table_number = 1; |
1310 | 1310 | $sql = $this->dbConnection->escapeDBItem($table_name); //Make by Pierre PIV (add escapeDBItem) |
@@ -1313,14 +1313,14 @@ discard block |
||
1313 | 1313 | throw new TDBMException("TODO: explainTree not implemented for only one table."); |
1314 | 1314 | } |
1315 | 1315 | else { |
1316 | - if ($hint_path!=null && $mode != 'explainTree') |
|
1316 | + if ($hint_path != null && $mode != 'explainTree') |
|
1317 | 1317 | { |
1318 | 1318 | $path = $hint_path; |
1319 | 1319 | $flat_path = $this->flatten_paths($path); |
1320 | 1320 | } |
1321 | 1321 | else |
1322 | 1322 | { |
1323 | - $full_paths = $this->static_find_paths($table_name,$needed_table_array); |
|
1323 | + $full_paths = $this->static_find_paths($table_name, $needed_table_array); |
|
1324 | 1324 | |
1325 | 1325 | if ($mode == 'explainTree') { |
1326 | 1326 | return $this->getTablePathsTree($full_paths); |
@@ -1373,7 +1373,7 @@ discard block |
||
1373 | 1373 | */ |
1374 | 1374 | $is_ok = true; |
1375 | 1375 | foreach ($path as $step) { |
1376 | - if ($step["type"]=="1*") { |
|
1376 | + if ($step["type"] == "1*") { |
|
1377 | 1377 | $is_ok = false; |
1378 | 1378 | break; |
1379 | 1379 | } |
@@ -1398,7 +1398,7 @@ discard block |
||
1398 | 1398 | $orderby_columns_array = array_merge($orderby_columns_array, $orderby_object->toSqlStatementsArray()); |
1399 | 1399 | } |
1400 | 1400 | |
1401 | - $orderby_statement = ' ORDER BY '.implode(',',$orderby_columns_array); |
|
1401 | + $orderby_statement = ' ORDER BY '.implode(',', $orderby_columns_array); |
|
1402 | 1402 | $count = 0; |
1403 | 1403 | foreach ($orderby_columns_array as $id=>$orderby_statement_phrase) { |
1404 | 1404 | // Let's remove the trailing ASC or DESC and add AS tdbm_reserved_col_Xxx |
@@ -1416,10 +1416,10 @@ discard block |
||
1416 | 1416 | $orderby_columns_array[$id] = $orderby_statement_phrase.' AS tdbm_reserved_col_'.$count; |
1417 | 1417 | $count++; |
1418 | 1418 | } |
1419 | - $orderby_column_statement = ', '.implode(',',$orderby_columns_array); |
|
1419 | + $orderby_column_statement = ', '.implode(',', $orderby_columns_array); |
|
1420 | 1420 | } |
1421 | 1421 | |
1422 | - if ($mode=="getCount") { |
|
1422 | + if ($mode == "getCount") { |
|
1423 | 1423 | // Let's get the list of primary keys to perform a DISTINCT request. |
1424 | 1424 | $pk_table = $this->getPrimaryKeyStatic($table_name); |
1425 | 1425 | |
@@ -1453,7 +1453,7 @@ discard block |
||
1453 | 1453 | if ($mode == 'explainSQL') { |
1454 | 1454 | return $sql; |
1455 | 1455 | } |
1456 | - return $this->getObjectsFromSQL($table_name, $sql, $from, $limit, $className); |
|
1456 | + return $this->getObjectsFromSQL($table_name, $sql, $from, $limit, $className); |
|
1457 | 1457 | |
1458 | 1458 | } |
1459 | 1459 | |
@@ -1478,19 +1478,19 @@ discard block |
||
1478 | 1478 | // Second, let's take all the objects out of the filter bag, and let's make filters from them |
1479 | 1479 | $filter_bag2 = array(); |
1480 | 1480 | foreach ($filter_bag as $thing) { |
1481 | - if (is_a($thing,'Mouf\\Database\\TDBM\\Filters\\FilterInterface')) { |
|
1481 | + if (is_a($thing, 'Mouf\\Database\\TDBM\\Filters\\FilterInterface')) { |
|
1482 | 1482 | $filter_bag2[] = $thing; |
1483 | - } elseif (is_a($thing,'Mouf\\Database\\TDBM\\TDBMObject')) { |
|
1483 | + } elseif (is_a($thing, 'Mouf\\Database\\TDBM\\TDBMObject')) { |
|
1484 | 1484 | $pk_table = $thing->getPrimaryKey(); |
1485 | 1485 | // If there is only one primary key: |
1486 | - if (count($pk_table)==1) { |
|
1486 | + if (count($pk_table) == 1) { |
|
1487 | 1487 | //$sql_where = "t1".$pk_table[0]."=".$this->db_connection->quoteSmart($this->TDBMObject_id); |
1488 | 1488 | $pkStr = $pk_table[0]; |
1489 | 1489 | $filter_bag2[] = new EqualFilter($thing->_getDbTableName(), $pk_table[0], $thing->$pkStr); |
1490 | 1490 | } else { |
1491 | 1491 | //$ids = unserialize($this->TDBMObject_id); |
1492 | 1492 | //$i=0; |
1493 | - $filter_bag_temp_and=array(); |
|
1493 | + $filter_bag_temp_and = array(); |
|
1494 | 1494 | foreach ($pk_table as $pk) { |
1495 | 1495 | $filter_bag_temp_and[] = new EqualFilter($thing->_getDbTableName(), $pk, $thing->$pk); |
1496 | 1496 | } |
@@ -1502,13 +1502,13 @@ discard block |
||
1502 | 1502 | //$filter_bag2[] = new EqualFilter($thing->_getDbTableName(), $primary_key, $thing->$primary_key); |
1503 | 1503 | } elseif (is_string($thing)) { |
1504 | 1504 | $filter_bag2[] = new SqlStringFilter($thing); |
1505 | - } elseif (is_a($thing,'Mouf\\Database\\TDBM\\TDBMObjectArray') && count($thing)>0) { |
|
1505 | + } elseif (is_a($thing, 'Mouf\\Database\\TDBM\\TDBMObjectArray') && count($thing)>0) { |
|
1506 | 1506 | // Get table_name and column_name |
1507 | 1507 | $filter_table_name = $thing[0]->_getDbTableName(); |
1508 | 1508 | $filter_column_names = $thing[0]->getPrimaryKey(); |
1509 | 1509 | |
1510 | 1510 | // If there is only one primary key, we can use the InFilter |
1511 | - if (count($filter_column_names)==1) { |
|
1511 | + if (count($filter_column_names) == 1) { |
|
1512 | 1512 | $primary_keys_array = array(); |
1513 | 1513 | $filter_column_name = $filter_column_names[0]; |
1514 | 1514 | foreach ($thing as $TDBMObject) { |
@@ -1521,7 +1521,7 @@ discard block |
||
1521 | 1521 | { |
1522 | 1522 | $filter_bag_and = array(); |
1523 | 1523 | foreach ($thing as $TDBMObject) { |
1524 | - $filter_bag_temp_and=array(); |
|
1524 | + $filter_bag_temp_and = array(); |
|
1525 | 1525 | foreach ($filter_column_names as $pk) { |
1526 | 1526 | $filter_bag_temp_and[] = new EqualFilter($TDBMObject->_getDbTableName(), $pk, $TDBMObject->$pk); |
1527 | 1527 | } |
@@ -1531,7 +1531,7 @@ discard block |
||
1531 | 1531 | } |
1532 | 1532 | |
1533 | 1533 | |
1534 | - } elseif (!is_a($thing,'Mouf\\Database\\TDBM\\TDBMObjectArray') && $thing!==null) { |
|
1534 | + } elseif (!is_a($thing, 'Mouf\\Database\\TDBM\\TDBMObjectArray') && $thing !== null) { |
|
1535 | 1535 | 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."); |
1536 | 1536 | } |
1537 | 1537 | } |
@@ -1559,9 +1559,9 @@ discard block |
||
1559 | 1559 | // 4-2, let's take all the objects out of the orderby bag, and let's make objects from them |
1560 | 1560 | $orderby_bag2 = array(); |
1561 | 1561 | foreach ($orderby_bag as $thing) { |
1562 | - if (is_a($thing,'Mouf\\Database\\TDBM\\Filters\\OrderBySQLString')) { |
|
1562 | + if (is_a($thing, 'Mouf\\Database\\TDBM\\Filters\\OrderBySQLString')) { |
|
1563 | 1563 | $orderby_bag2[] = $thing; |
1564 | - } elseif (is_a($thing,'Mouf\\Database\\TDBM\\Filters\\OrderByColumn')) { |
|
1564 | + } elseif (is_a($thing, 'Mouf\\Database\\TDBM\\Filters\\OrderByColumn')) { |
|
1565 | 1565 | $orderby_bag2[] = $thing; |
1566 | 1566 | } elseif (is_string($thing)) { |
1567 | 1567 | $orderby_bag2[] = new OrderBySQLString($thing); |
@@ -1583,10 +1583,10 @@ discard block |
||
1583 | 1583 | $possible_tables = $this->dbConnection->checkTableExist($table); |
1584 | 1584 | if ($possible_tables !== true) |
1585 | 1585 | { |
1586 | - if (count($possible_tables)==1) |
|
1586 | + if (count($possible_tables) == 1) |
|
1587 | 1587 | $str = "Could not find table '$table'. Maybe you meant this table: '".$possible_tables[0]."'"; |
1588 | 1588 | else |
1589 | - $str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$possible_tables)."'"; |
|
1589 | + $str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '", $possible_tables)."'"; |
|
1590 | 1590 | throw new TDBMException($str); |
1591 | 1591 | } |
1592 | 1592 | } |
@@ -1615,16 +1615,16 @@ discard block |
||
1615 | 1615 | $current_node = $tree; |
1616 | 1616 | $found = true; |
1617 | 1617 | foreach ($path as $link) { |
1618 | - if ($found==true) |
|
1618 | + if ($found == true) |
|
1619 | 1619 | { |
1620 | 1620 | if (is_array($current_node->getChildren())) |
1621 | 1621 | { |
1622 | 1622 | foreach ($current_node->getChildren() as $child) |
1623 | 1623 | { |
1624 | - if ($link['table1']==$child->table_name && |
|
1625 | - $link['col1']==$child->keyNode && |
|
1626 | - $link['col2']==$child->keyParent && |
|
1627 | - $link['type']==$child->link_type) { |
|
1624 | + if ($link['table1'] == $child->table_name && |
|
1625 | + $link['col1'] == $child->keyNode && |
|
1626 | + $link['col2'] == $child->keyParent && |
|
1627 | + $link['type'] == $child->link_type) { |
|
1628 | 1628 | $current_node = $child; |
1629 | 1629 | } |
1630 | 1630 | else |
@@ -1639,7 +1639,7 @@ discard block |
||
1639 | 1639 | |
1640 | 1640 | } |
1641 | 1641 | |
1642 | - if ($found==false) |
|
1642 | + if ($found == false) |
|
1643 | 1643 | { |
1644 | 1644 | $current_node = new DisplayNode($link['table1'], $current_node, $link['type'], $link['col2'], $link['col1']); |
1645 | 1645 | /*if ($link['type']=='*1') |
@@ -1662,7 +1662,7 @@ discard block |
||
1662 | 1662 | * |
1663 | 1663 | * @param unknown_type $tree |
1664 | 1664 | */ |
1665 | - public function drawTree($tree, $x, $y, &$ret_width=0, &$ret_height=0) { |
|
1665 | + public function drawTree($tree, $x, $y, &$ret_width = 0, &$ret_height = 0) { |
|
1666 | 1666 | |
1667 | 1667 | // Let's get the background div: |
1668 | 1668 | $treeDepth = $tree->computeDepth(1)-1; |
@@ -1673,7 +1673,7 @@ discard block |
||
1673 | 1673 | |
1674 | 1674 | $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>"; |
1675 | 1675 | |
1676 | - $str .= $tree->draw(0,0, $x, $y); |
|
1676 | + $str .= $tree->draw(0, 0, $x, $y); |
|
1677 | 1677 | |
1678 | 1678 | return $str; |
1679 | 1679 | |
@@ -1709,10 +1709,10 @@ discard block |
||
1709 | 1709 | if ($tables === true) |
1710 | 1710 | throw new TDBMException("Could not find table primary key for table '$table'. Please define a primary key for this table."); |
1711 | 1711 | elseif ($tables !== null) { |
1712 | - if (count($tables)==1) |
|
1712 | + if (count($tables) == 1) |
|
1713 | 1713 | $str = "Could not find table '$table'. Maybe you meant this table: '".$tables[0]."'"; |
1714 | 1714 | else |
1715 | - $str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$tables)."'"; |
|
1715 | + $str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '", $tables)."'"; |
|
1716 | 1716 | throw new TDBMException($str); |
1717 | 1717 | } |
1718 | 1718 | } |
@@ -406,10 +406,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @Action |
44 | 44 | * //@Admin |
45 | 45 | */ |
46 | - public function defaultAction($name, $selfedit="false") { |
|
46 | + public function defaultAction($name, $selfedit = "false") { |
|
47 | 47 | $this->initController($name, $selfedit); |
48 | 48 | |
49 | 49 | // Fill variables |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @param string $name |
95 | 95 | * @param bool $selfedit |
96 | 96 | */ |
97 | - public function generate($name, $sourcedirectory, $daonamespace, $beannamespace, $daofactoryclassname, $daofactoryinstancename, $keepSupport = 0, $storeInUtc = 0,$selfedit="false") { |
|
97 | + public function generate($name, $sourcedirectory, $daonamespace, $beannamespace, $daofactoryclassname, $daofactoryinstancename, $keepSupport = 0, $storeInUtc = 0, $selfedit = "false") { |
|
98 | 98 | $this->initController($name, $selfedit); |
99 | 99 | |
100 | 100 | self::generateDaos($this->moufManager, $name, $sourcedirectory, $daonamespace, $beannamespace, $daofactoryclassname, $daofactoryinstancename, $selfedit, $keepSupport, $storeInUtc); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * This function generates the DAOs and Beans for the TDBM service passed in parameter. |
108 | 108 | * |
109 | 109 | */ |
110 | - public static function generateDaos(MoufManager $moufManager, $name, $sourcedirectory, $daonamespace, $beannamespace, $daofactoryclassname, $daofactoryinstancename, $selfedit="false", $keepSupport = null, $storeInUtc = null) { |
|
110 | + public static function generateDaos(MoufManager $moufManager, $name, $sourcedirectory, $daonamespace, $beannamespace, $daofactoryclassname, $daofactoryinstancename, $selfedit = "false", $keepSupport = null, $storeInUtc = null) { |
|
111 | 111 | $moufManager->setVariable("tdbmDefaultSourceDirectory_".$name, $sourcedirectory); |
112 | 112 | $moufManager->setVariable("tdbmDefaultDaoNamespace_".$name, $daonamespace); |
113 | 113 | $moufManager->setVariable("tdbmDefaultBeanNamespace_".$name, $beannamespace); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | <div class="control-group"> |
53 | 53 | <label class="control-label">Keep support for previous DAOs:</label> |
54 | 54 | <div class="controls"> |
55 | - <input type="checkbox" name="keepSupport" <?php echo $this->keepSupport?'checked="checked"':"" ?>></input> |
|
55 | + <input type="checkbox" name="keepSupport" <?php echo $this->keepSupport ? 'checked="checked"' : "" ?>></input> |
|
56 | 56 | <span class="help-block">DAOs generated before TDBM 2.3 had a different method signature. This will ensure this signature |
57 | 57 | is respected. Use this only if you are migrating legacy code.</span> |
58 | 58 | </div> |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | <div class="control-group"> |
62 | 62 | <label class="control-label">Store dates / timestamps in UTC:</label> |
63 | 63 | <div class="controls"> |
64 | - <input type="checkbox" name="storeInUtc" value="1" <?php echo $this->storeInUtc?'checked="checked"':"" ?>></input> |
|
64 | + <input type="checkbox" name="storeInUtc" value="1" <?php echo $this->storeInUtc ? 'checked="checked"' : "" ?>></input> |
|
65 | 65 | <span class="help-block">Select this option if you want timestamps to be stored in UTC. |
66 | 66 | If your application supports several time zones, you should select this option to store all dates in |
67 | 67 | the same time zone.</span> |