@@ -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; |
@@ -45,7 +45,7 @@ |
||
45 | 45 | <div class="control-group"> |
46 | 46 | <label class="control-label">Store dates / timestamps in UTC:</label> |
47 | 47 | <div class="controls"> |
48 | - <input type="checkbox" name="storeInUtc" value="1" <?php echo $this->storeInUtc?'checked="checked"':"" ?>></input> |
|
48 | + <input type="checkbox" name="storeInUtc" value="1" <?php echo $this->storeInUtc ? 'checked="checked"' : "" ?>></input> |
|
49 | 49 | <span class="help-block">Select this option if you want timestamps to be stored in UTC. |
50 | 50 | If your application supports several time zones, you should select this option to store all dates in |
51 | 51 | the same time zone.</span> |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $baseBeanName = $this->getBaseBeanNameFromTableName($tableName); |
100 | 100 | |
101 | 101 | $connection = $this->dbConnection; |
102 | - if ($connection instanceof CachedConnection){ |
|
102 | + if ($connection instanceof CachedConnection) { |
|
103 | 103 | $connection->cacheService->purgeAll(); |
104 | 104 | } |
105 | 105 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | if($date === null) |
198 | 198 | return null; |
199 | 199 | else |
200 | - return strtotime($date'.($this->storeInUtc?'.\' UTC\'':'').'); |
|
200 | + return strtotime($date'.($this->storeInUtc ? '.\' UTC\'' : '').'); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | if ($this->'.$array["col1"].' == null) { |
288 | 288 | return null; |
289 | 289 | } |
290 | - return $this->tdbmService->getObject("'.$array["table2"].'", $this->'.$array["col1"].', "'.str_replace("\\","\\\\",$this->beanNamespace).'\\\\'.$referencedBeanName.'", true); |
|
290 | + return $this->tdbmService->getObject("'.$array["table2"].'", $this->'.$array["col1"].', "'.str_replace("\\", "\\\\", $this->beanNamespace).'\\\\'.$referencedBeanName.'", true); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
@@ -306,10 +306,10 @@ discard block |
||
306 | 306 | |
307 | 307 | // Now, let's implement the shortcuts to the getter of objects. |
308 | 308 | // Shortcuts are used to save typing. They are available only if a referenced table is referenced only once by our tables. |
309 | - foreach($referencedTablesList as $referrencedTable=>$number) { |
|
309 | + foreach ($referencedTablesList as $referrencedTable=>$number) { |
|
310 | 310 | if ($number == 1) { |
311 | 311 | foreach ($constraints as $array) { |
312 | - if ($array['table2'] ==$referrencedTable) { |
|
312 | + if ($array['table2'] == $referrencedTable) { |
|
313 | 313 | $columnName = $array['col1']; |
314 | 314 | $targetColumnName = $array['col2']; |
315 | 315 | break; |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | if ($this->'.$array["col1"].' == null) { |
341 | 341 | return null; |
342 | 342 | } |
343 | - return $this->tdbmService->getObject("'.$array["table2"].'", $this->'.$array["col1"].', "'.str_replace("\\","\\\\",$this->beanNamespace).'\\\\'.$referencedBeanName.'"); |
|
343 | + return $this->tdbmService->getObject("'.$array["table2"].'", $this->'.$array["col1"].', "'.str_replace("\\", "\\\\", $this->beanNamespace).'\\\\'.$referencedBeanName.'"); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | |
399 | 399 | }"; |
400 | 400 | $this->ensureDirectoryExist($possibleFileName); |
401 | - file_put_contents($possibleFileName ,$str); |
|
401 | + file_put_contents($possibleFileName, $str); |
|
402 | 402 | @chmod($possibleFileName, 0664); |
403 | 403 | } |
404 | 404 | } |
@@ -416,11 +416,11 @@ discard block |
||
416 | 416 | foreach ($info as $index => $data) { |
417 | 417 | $comments = $data['column_comment']; |
418 | 418 | $matches = array(); |
419 | - if (preg_match('/@defaultSort(\((desc|asc)\))*/', $comments, $matches) != 0){ |
|
419 | + if (preg_match('/@defaultSort(\((desc|asc)\))*/', $comments, $matches) != 0) { |
|
420 | 420 | $defaultSort = $data['column_name']; |
421 | - if (count($matches == 3)){ |
|
421 | + if (count($matches == 3)) { |
|
422 | 422 | $defaultSortDirection = $matches[2]; |
423 | - }else{ |
|
423 | + } else { |
|
424 | 424 | $defaultSortDirection = 'ASC'; |
425 | 425 | } |
426 | 426 | } |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | $possibleBaseFileName = __DIR__.'/../../../../../../../../'.$possibleBaseFileNames[0]; |
661 | 661 | |
662 | 662 | $this->ensureDirectoryExist($possibleBaseFileName); |
663 | - file_put_contents($possibleBaseFileName ,$str); |
|
663 | + file_put_contents($possibleBaseFileName, $str); |
|
664 | 664 | @chmod($possibleBaseFileName, 0664); |
665 | 665 | |
666 | 666 | $possibleFileNames = $classNameMapper->getPossibleFileNames($this->daoNamespace."\\".$className); |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | |
689 | 689 | }"; |
690 | 690 | $this->ensureDirectoryExist($possibleFileName); |
691 | - file_put_contents($possibleFileName ,$str); |
|
691 | + file_put_contents($possibleFileName, $str); |
|
692 | 692 | @chmod($possibleFileName, 0664); |
693 | 693 | } |
694 | 694 | } |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | $possibleFileName = __DIR__.'/../../../../../../../../'.$possibleFileNames[0]; |
762 | 762 | |
763 | 763 | $this->ensureDirectoryExist($possibleFileName); |
764 | - file_put_contents($possibleFileName ,$str); |
|
764 | + file_put_contents($possibleFileName, $str); |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | /** |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | * @return string |
829 | 829 | */ |
830 | 830 | public static function toCamelCase($str) { |
831 | - $str = strtoupper(substr($str,0,1)).substr($str,1); |
|
831 | + $str = strtoupper(substr($str, 0, 1)).substr($str, 1); |
|
832 | 832 | while (true) { |
833 | 833 | if (strpos($str, "_") === false && strpos($str, " ") === false) |
834 | 834 | break; |
@@ -837,9 +837,9 @@ discard block |
||
837 | 837 | if ($pos === false) { |
838 | 838 | $pos = strpos($str, " "); |
839 | 839 | } |
840 | - $before = substr($str,0,$pos); |
|
841 | - $after = substr($str,$pos+1); |
|
842 | - $str = $before.strtoupper(substr($after,0,1)).substr($after,1); |
|
840 | + $before = substr($str, 0, $pos); |
|
841 | + $after = substr($str, $pos+1); |
|
842 | + $str = $before.strtoupper(substr($after, 0, 1)).substr($after, 1); |
|
843 | 843 | } |
844 | 844 | return $str; |
845 | 845 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @Action |
42 | 42 | * //@Admin |
43 | 43 | */ |
44 | - public function defaultAction($name, $selfedit="false") { |
|
44 | + public function defaultAction($name, $selfedit = "false") { |
|
45 | 45 | $this->initController($name, $selfedit); |
46 | 46 | |
47 | 47 | // Fill variables |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param string $name |
91 | 91 | * @param bool $selfedit |
92 | 92 | */ |
93 | - public function generate($name, $daonamespace, $beannamespace, $daofactoryclassname, $daofactoryinstancename, $keepSupport = 0, $storeInUtc = 0,$selfedit="false") { |
|
93 | + public function generate($name, $daonamespace, $beannamespace, $daofactoryclassname, $daofactoryinstancename, $keepSupport = 0, $storeInUtc = 0, $selfedit = "false") { |
|
94 | 94 | $this->initController($name, $selfedit); |
95 | 95 | |
96 | 96 | self::generateDaos($this->moufManager, $name, $daonamespace, $beannamespace, $daofactoryclassname, $daofactoryinstancename, $selfedit, $keepSupport, $storeInUtc); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * This function generates the DAOs and Beans for the TDBM service passed in parameter. |
104 | 104 | * |
105 | 105 | */ |
106 | - public static function generateDaos(MoufManager $moufManager, $name, $daonamespace, $beannamespace, $daofactoryclassname, $daofactoryinstancename, $selfedit="false", $keepSupport = null, $storeInUtc = null) { |
|
106 | + public static function generateDaos(MoufManager $moufManager, $name, $daonamespace, $beannamespace, $daofactoryclassname, $daofactoryinstancename, $selfedit = "false", $keepSupport = null, $storeInUtc = null) { |
|
107 | 107 | $moufManager->setVariable("tdbmDefaultDaoNamespace_".$name, $daonamespace); |
108 | 108 | $moufManager->setVariable("tdbmDefaultBeanNamespace_".$name, $beannamespace); |
109 | 109 | $moufManager->setVariable("tdbmDefaultDaoFactoryName_".$name, $daofactoryclassname); |
@@ -141,7 +141,7 @@ |
||
141 | 141 | * @param int $storeInUtc |
142 | 142 | * @param string $selfedit |
143 | 143 | */ |
144 | - public function generate($daonamespace, $beannamespace, $keepSupport = 0, $storeInUtc = 0, $selfedit="false") { |
|
144 | + public function generate($daonamespace, $beannamespace, $keepSupport = 0, $storeInUtc = 0, $selfedit = "false") { |
|
145 | 145 | $this->selfedit = $selfedit; |
146 | 146 | |
147 | 147 | if ($selfedit == "true") { |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | private $cacheKey = "__TDBM_Cache__"; |
143 | 143 | |
144 | 144 | public function __construct() { |
145 | - register_shutdown_function(array($this,"completeSaveOnExit")); |
|
145 | + register_shutdown_function(array($this, "completeSaveOnExit")); |
|
146 | 146 | if (extension_loaded('weakref')) { |
147 | 147 | $this->objectStorage = new WeakrefObjectStorage(); |
148 | 148 | } else { |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | $objects = $this->getObjects($table_name, $filters, null, null, null, $className); |
363 | 363 | if (count($objects) == 0) { |
364 | 364 | return null; |
365 | - } elseif (count($objects) > 1) { |
|
365 | + } elseif (count($objects)>1) { |
|
366 | 366 | 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."); |
367 | 367 | } |
368 | 368 | // Return the first and only object. |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * @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. |
436 | 436 | * @return TDBMObject |
437 | 437 | */ |
438 | - public function getNewObject($table_name, $auto_assign_id=true, $className = null) { |
|
438 | + public function getNewObject($table_name, $auto_assign_id = true, $className = null) { |
|
439 | 439 | if ($this->dbConnection == null) { |
440 | 440 | throw new TDBMException("Error while calling TDBMObject::getNewObject(): No connection has been established on the database!"); |
441 | 441 | } |
@@ -465,8 +465,8 @@ discard block |
||
465 | 465 | } |
466 | 466 | |
467 | 467 | if ($auto_assign_id && !$this->isPrimaryKeyAutoIncrement($table_name)) { |
468 | - $pk_table = $this->getPrimaryKeyStatic($table_name); |
|
469 | - if (count($pk_table)==1) |
|
468 | + $pk_table = $this->getPrimaryKeyStatic($table_name); |
|
469 | + if (count($pk_table) == 1) |
|
470 | 470 | { |
471 | 471 | $root_table = $this->dbConnection->findRootSequenceTable($table_name); |
472 | 472 | $id = $this->dbConnection->nextId($root_table); |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | $sql = "SELECT MAX(".$this->dbConnection->escapeDBItem($pk_table[0]).") AS maxkey FROM ".$root_table; |
477 | 477 | $res = $this->dbConnection->getAll($sql); |
478 | 478 | // NOTE: this will work only if the ID is an integer! |
479 | - $newid = $res[0]['maxkey'] + 1; |
|
479 | + $newid = $res[0]['maxkey']+1; |
|
480 | 480 | if ($newid>$id) { |
481 | 481 | $id = $newid; |
482 | 482 | } |
@@ -506,17 +506,17 @@ discard block |
||
506 | 506 | // Now for the object_id |
507 | 507 | $object_id = $object->TDBMObject_id; |
508 | 508 | // If there is only one primary key: |
509 | - if (count($pk_table)==1) { |
|
509 | + if (count($pk_table) == 1) { |
|
510 | 510 | $sql_where = $this->dbConnection->escapeDBItem($pk_table[0])."=".$this->dbConnection->quoteSmart($object->TDBMObject_id); |
511 | 511 | } else { |
512 | 512 | $ids = unserialize($object_id); |
513 | - $i=0; |
|
513 | + $i = 0; |
|
514 | 514 | $sql_where_array = array(); |
515 | 515 | foreach ($pk_table as $pk) { |
516 | 516 | $sql_where_array[] = $this->dbConnection->escapeDBItem($pk)."=".$this->dbConnection->quoteSmart($ids[$i]); |
517 | 517 | $i++; |
518 | 518 | } |
519 | - $sql_where = implode(" AND ",$sql_where_array); |
|
519 | + $sql_where = implode(" AND ", $sql_where_array); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | * @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. |
600 | 600 | * @return array|Generator|TDBMObjectArray The result set of the query as a TDBMObjectArray (an array of TDBMObjects with special properties) |
601 | 601 | */ |
602 | - public function getObjectsFromSQL($table_name, $sql, $from=null, $limit=null, $className=null) { |
|
602 | + public function getObjectsFromSQL($table_name, $sql, $from = null, $limit = null, $className = null) { |
|
603 | 603 | if ($this->dbConnection == null) { |
604 | 604 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
605 | 605 | } |
@@ -630,10 +630,10 @@ discard block |
||
630 | 630 | $firstLine = false; |
631 | 631 | } |
632 | 632 | foreach ($fullCaseRow as $key=>$value) { |
633 | - $row[$keysStandardCased[$key]]=$value; |
|
633 | + $row[$keysStandardCased[$key]] = $value; |
|
634 | 634 | } |
635 | 635 | $pk_table = $this->primary_keys[$table_name]; |
636 | - if (count($pk_table)==1) |
|
636 | + if (count($pk_table) == 1) |
|
637 | 637 | { |
638 | 638 | if (!isset($keysStandardCased[$pk_table[0]])) { |
639 | 639 | 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); |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | $id = serialize($ids); |
651 | 651 | } |
652 | 652 | |
653 | - $obj = $this->objectStorage->get($table_name,$id); |
|
653 | + $obj = $this->objectStorage->get($table_name, $id); |
|
654 | 654 | if ($obj === null) |
655 | 655 | { |
656 | 656 | if ($className == null) { |
@@ -715,10 +715,10 @@ discard block |
||
715 | 715 | $firstLine = false; |
716 | 716 | } |
717 | 717 | foreach ($fullCaseRow as $key=>$value) { |
718 | - $row[$keysStandardCased[$key]]=$value; |
|
718 | + $row[$keysStandardCased[$key]] = $value; |
|
719 | 719 | } |
720 | 720 | $pk_table = $this->primary_keys[$table_name]; |
721 | - if (count($pk_table)==1) |
|
721 | + if (count($pk_table) == 1) |
|
722 | 722 | { |
723 | 723 | if (!isset($keysStandardCased[$pk_table[0]])) { |
724 | 724 | 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); |
@@ -813,14 +813,14 @@ discard block |
||
813 | 813 | // Now, let's commit or rollback if needed. |
814 | 814 | if ($this->dbConnection != null && $this->dbConnection->hasActiveTransaction()) { |
815 | 815 | if ($this->commitOnQuit) { |
816 | - try { |
|
816 | + try { |
|
817 | 817 | $this->dbConnection->commit(); |
818 | 818 | } catch (Exception $e) { |
819 | 819 | echo $e->getMessage()."<br/>"; |
820 | 820 | echo $e->getTraceAsString(); |
821 | 821 | } |
822 | 822 | } else { |
823 | - try { |
|
823 | + try { |
|
824 | 824 | $this->dbConnection->rollback(); |
825 | 825 | } catch (Exception $e) { |
826 | 826 | echo $e->getMessage()."<br/>"; |
@@ -881,21 +881,21 @@ discard block |
||
881 | 881 | * @param string $sql |
882 | 882 | * @return array the result of your query |
883 | 883 | */ |
884 | - public function getTransientObjectsFromSQL($sql,$classname=null) { |
|
884 | + public function getTransientObjectsFromSQL($sql, $classname = null) { |
|
885 | 885 | if ($this->dbConnection == null) { |
886 | 886 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
887 | 887 | } |
888 | - return $this->dbConnection->getAll($sql, \PDO::FETCH_CLASS,$classname); |
|
888 | + return $this->dbConnection->getAll($sql, \PDO::FETCH_CLASS, $classname); |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | |
892 | 892 | private function to_explain_string($path) { |
893 | 893 | $msg = ''; |
894 | 894 | foreach ($path as $constraint) { |
895 | - if ($constraint['type']=='1*') { |
|
895 | + if ($constraint['type'] == '1*') { |
|
896 | 896 | $msg .= 'Table "'.$constraint['table1'].'" points to "'.$constraint['table2'].'" through its foreign key "'.$constraint['col1'].'"\n'; |
897 | 897 | } |
898 | - elseif ($constraint['type']=='*1') { |
|
898 | + elseif ($constraint['type'] == '*1') { |
|
899 | 899 | $msg .= 'Table "'.$constraint['table1'].'" is pointed by "'.$constraint['table2'].'" through its foreign key "'.$constraint['col2'].'"\n'; |
900 | 900 | } |
901 | 901 | } |
@@ -914,7 +914,7 @@ discard block |
||
914 | 914 | $this->loadCache(); |
915 | 915 | |
916 | 916 | $path = array(); |
917 | - $queue = array(array($table,array())); |
|
917 | + $queue = array(array($table, array())); |
|
918 | 918 | |
919 | 919 | $found = false; |
920 | 920 | $found_depth = 0; |
@@ -949,7 +949,7 @@ discard block |
||
949 | 949 | { |
950 | 950 | break; |
951 | 951 | } |
952 | - if ($ret==true) |
|
952 | + if ($ret == true) |
|
953 | 953 | { |
954 | 954 | // Ok, we got one, we will continue a bit more until we reach the next level in the tree, |
955 | 955 | // just to see if there is no ambiguity |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | } |
960 | 960 | |
961 | 961 | // At each iteration, let's check the time. |
962 | - if ($this->trackExecutionTime && microtime(true)-self::$script_start_up_time > $max_execution_time && $max_execution_time!=0) { |
|
962 | + if ($this->trackExecutionTime && microtime(true)-self::$script_start_up_time>$max_execution_time && $max_execution_time != 0) { |
|
963 | 963 | // Call check table names |
964 | 964 | $this->checkTablesExist($tables); |
965 | 965 | |
@@ -970,11 +970,11 @@ discard block |
||
970 | 970 | } |
971 | 971 | } |
972 | 972 | |
973 | - $ambiguity =false; |
|
973 | + $ambiguity = false; |
|
974 | 974 | $msg = ''; |
975 | 975 | foreach ($tables_paths as $table_path) { |
976 | 976 | // If any table has not been found, throw an exception |
977 | - if (!isset($table_path['founddepth']) || $table_path['founddepth']==null) { |
|
977 | + if (!isset($table_path['founddepth']) || $table_path['founddepth'] == null) { |
|
978 | 978 | // First, check if the tables do exist. |
979 | 979 | $this->checkTablesExist(array($table, $table_path['name'])); |
980 | 980 | // Else, throw an error. |
@@ -1036,7 +1036,7 @@ discard block |
||
1036 | 1036 | 'table2' => $depArr['table1'], |
1037 | 1037 | 'col1' => $depArr['col2'], |
1038 | 1038 | 'col2' => $depArr['col1'], |
1039 | - 'type' => (($depArr['type'] == '1*')?'*1':'1*') |
|
1039 | + 'type' => (($depArr['type'] == '1*') ? '*1' : '1*') |
|
1040 | 1040 | ); |
1041 | 1041 | }, $toRevertPath); |
1042 | 1042 | return array_reverse($invertedDependencies); |
@@ -1054,7 +1054,7 @@ discard block |
||
1054 | 1054 | * @param unknown_type $paths |
1055 | 1055 | */ |
1056 | 1056 | private function flatten_paths($paths) { |
1057 | - $flat_path=array(); |
|
1057 | + $flat_path = array(); |
|
1058 | 1058 | foreach ($paths as $path_bigarray) { |
1059 | 1059 | $path = $path_bigarray['paths'][0]; |
1060 | 1060 | |
@@ -1093,9 +1093,9 @@ discard block |
||
1093 | 1093 | $path = $current_vars[1]; |
1094 | 1094 | |
1095 | 1095 | foreach ($target_tables as $id=>$target_table) { |
1096 | - if ($target_table['name'] == $current_table && (!isset($target_table['founddepth']) || $target_table['founddepth']==null || $target_table['founddepth']==count($path))) { |
|
1096 | + if ($target_table['name'] == $current_table && (!isset($target_table['founddepth']) || $target_table['founddepth'] == null || $target_table['founddepth'] == count($path))) { |
|
1097 | 1097 | // When a path is found to a table, we mark the table as found with its depth. |
1098 | - $target_tables[$id]['founddepth']=count($path); |
|
1098 | + $target_tables[$id]['founddepth'] = count($path); |
|
1099 | 1099 | |
1100 | 1100 | // Then we add the path to table to the target_tables array |
1101 | 1101 | $target_tables[$id]['paths'][] = $path; |
@@ -1126,13 +1126,13 @@ discard block |
||
1126 | 1126 | $already_done = false; |
1127 | 1127 | foreach ($path as $previous_constraint) |
1128 | 1128 | { |
1129 | - if ($previous_constraint['type']=='1*' && $current_table == $previous_constraint["table2"] && $col2 == $previous_constraint["col2"] && $table1 == $previous_constraint["table1"] && $col1 == $previous_constraint["col1"]) |
|
1129 | + if ($previous_constraint['type'] == '1*' && $current_table == $previous_constraint["table2"] && $col2 == $previous_constraint["col2"] && $table1 == $previous_constraint["table1"] && $col1 == $previous_constraint["col1"]) |
|
1130 | 1130 | { |
1131 | 1131 | //echo "YOUHOU1! $current_table $col2"; |
1132 | 1132 | $already_done = true; |
1133 | 1133 | break; |
1134 | 1134 | } |
1135 | - elseif ($previous_constraint['type']=='*1' && $current_table == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"] && $table1 == $previous_constraint["table2"] && $col1 == $previous_constraint["col2"]) |
|
1135 | + elseif ($previous_constraint['type'] == '*1' && $current_table == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"] && $table1 == $previous_constraint["table2"] && $col1 == $previous_constraint["col2"]) |
|
1136 | 1136 | { |
1137 | 1137 | //echo "YOUHOU2! $current_table $col2"; |
1138 | 1138 | $already_done = true; |
@@ -1161,12 +1161,12 @@ discard block |
||
1161 | 1161 | $already_done = false; |
1162 | 1162 | foreach ($path as $previous_constraint) |
1163 | 1163 | { |
1164 | - if ($previous_constraint['type']=='1*' && $table2 == $previous_constraint["table2"] && $col2 == $previous_constraint["col2"]) |
|
1164 | + if ($previous_constraint['type'] == '1*' && $table2 == $previous_constraint["table2"] && $col2 == $previous_constraint["col2"]) |
|
1165 | 1165 | { |
1166 | 1166 | $already_done = true; |
1167 | 1167 | break; |
1168 | 1168 | } |
1169 | - elseif ($previous_constraint['type']=='*1' && $table2 == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"]) |
|
1169 | + elseif ($previous_constraint['type'] == '*1' && $table2 == $previous_constraint["table1"] && $col2 == $previous_constraint["col1"]) |
|
1170 | 1170 | { |
1171 | 1171 | $already_done = true; |
1172 | 1172 | break; |
@@ -1275,7 +1275,7 @@ discard block |
||
1275 | 1275 | * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null). |
1276 | 1276 | * @return TDBMObjectArray A TDBMObjectArray containing the resulting objects of the query. |
1277 | 1277 | */ |
1278 | - public function getObjects($table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $className=null, $hint_path=null) { |
|
1278 | + public function getObjects($table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $className = null, $hint_path = null) { |
|
1279 | 1279 | if ($this->dbConnection == null) { |
1280 | 1280 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
1281 | 1281 | } |
@@ -1291,7 +1291,7 @@ discard block |
||
1291 | 1291 | * @param unknown_type $hint_path |
1292 | 1292 | * @return integer |
1293 | 1293 | */ |
1294 | - public function getCount($table_name, $filter_bag=null, $hint_path=null) { |
|
1294 | + public function getCount($table_name, $filter_bag = null, $hint_path = null) { |
|
1295 | 1295 | if ($this->dbConnection == null) { |
1296 | 1296 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
1297 | 1297 | } |
@@ -1309,7 +1309,7 @@ discard block |
||
1309 | 1309 | * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null). |
1310 | 1310 | * @return string The SQL that would be executed. |
1311 | 1311 | */ |
1312 | - public function explainSQLGetObjects($table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $hint_path=null) { |
|
1312 | + public function explainSQLGetObjects($table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $hint_path = null) { |
|
1313 | 1313 | if ($this->dbConnection == null) { |
1314 | 1314 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
1315 | 1315 | } |
@@ -1327,7 +1327,7 @@ discard block |
||
1327 | 1327 | * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null). |
1328 | 1328 | * @return string The SQL that would be executed. |
1329 | 1329 | */ |
1330 | - public function explainRequestAsTextGetObjects($table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $hint_path=null) { |
|
1330 | + public function explainRequestAsTextGetObjects($table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $hint_path = null) { |
|
1331 | 1331 | if ($this->dbConnection == null) { |
1332 | 1332 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
1333 | 1333 | } |
@@ -1348,12 +1348,12 @@ discard block |
||
1348 | 1348 | * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null). |
1349 | 1349 | * @return string The SQL that would be executed. |
1350 | 1350 | */ |
1351 | - public function explainRequestAsHTMLGetObjects($table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $hint_path=null, $x=10, $y=10) { |
|
1351 | + public function explainRequestAsHTMLGetObjects($table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $hint_path = null, $x = 10, $y = 10) { |
|
1352 | 1352 | if ($this->dbConnection == null) { |
1353 | 1353 | throw new TDBMException("Error while calling TDBMObject::getObject(): No connection has been established on the database!"); |
1354 | 1354 | } |
1355 | 1355 | $tree = $this->getObjectsByMode('explainTree', $table_name, $filter_bag, $orderby_bag, $from, $limit, $hint_path); |
1356 | - return $this->drawTree($tree,$x,$y); |
|
1356 | + return $this->drawTree($tree, $x, $y); |
|
1357 | 1357 | } |
1358 | 1358 | |
1359 | 1359 | /** |
@@ -1370,7 +1370,7 @@ discard block |
||
1370 | 1370 | * @param unknown_type $hint_path Hints to get the path for the query (expert parameter, you should leave it to null). |
1371 | 1371 | * @return array|Generator|TDBMObjectArray An array or object containing the resulting objects of the query. |
1372 | 1372 | */ |
1373 | - public function getObjectsByMode($mode, $table_name, $filter_bag=null, $orderby_bag=null, $from=null, $limit=null, $className=null, $hint_path=null) { |
|
1373 | + public function getObjectsByMode($mode, $table_name, $filter_bag = null, $orderby_bag = null, $from = null, $limit = null, $className = null, $hint_path = null) { |
|
1374 | 1374 | $this->completeSave(); |
1375 | 1375 | $this->loadCache(); |
1376 | 1376 | |
@@ -1409,7 +1409,7 @@ discard block |
||
1409 | 1409 | } |
1410 | 1410 | } |
1411 | 1411 | |
1412 | - if (count($needed_table_array)==0) |
|
1412 | + if (count($needed_table_array) == 0) |
|
1413 | 1413 | { |
1414 | 1414 | $sql = $this->dbConnection->escapeDBItem($table_name); //Make by Pierre PIV (add escapeDBItem) |
1415 | 1415 | |
@@ -1417,14 +1417,14 @@ discard block |
||
1417 | 1417 | throw new TDBMException("TODO: explainTree not implemented for only one table."); |
1418 | 1418 | } |
1419 | 1419 | else { |
1420 | - if ($hint_path!=null && $mode != 'explainTree') |
|
1420 | + if ($hint_path != null && $mode != 'explainTree') |
|
1421 | 1421 | { |
1422 | 1422 | $path = $hint_path; |
1423 | 1423 | $flat_path = $this->flatten_paths($path); |
1424 | 1424 | } |
1425 | 1425 | else |
1426 | 1426 | { |
1427 | - $full_paths = $this->static_find_paths($table_name,$needed_table_array); |
|
1427 | + $full_paths = $this->static_find_paths($table_name, $needed_table_array); |
|
1428 | 1428 | |
1429 | 1429 | if ($mode == 'explainTree') { |
1430 | 1430 | return $this->getTablePathsTree($full_paths); |
@@ -1455,7 +1455,7 @@ discard block |
||
1455 | 1455 | |
1456 | 1456 | |
1457 | 1457 | //If no $hint_path is provided, check that a path exists |
1458 | - if($hint_path === null){ |
|
1458 | + if ($hint_path === null) { |
|
1459 | 1459 | // 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 |
1460 | 1460 | foreach ($needed_table_array_for_orderby as $target_table_table) { |
1461 | 1461 | // Get the path between the main table and the target group by table |
@@ -1471,7 +1471,7 @@ discard block |
||
1471 | 1471 | */ |
1472 | 1472 | $is_ok = true; |
1473 | 1473 | foreach ($path as $step) { |
1474 | - if ($step["type"]=="1*") { |
|
1474 | + if ($step["type"] == "1*") { |
|
1475 | 1475 | $is_ok = false; |
1476 | 1476 | break; |
1477 | 1477 | } |
@@ -1497,7 +1497,7 @@ discard block |
||
1497 | 1497 | $orderby_columns_array = array_merge($orderby_columns_array, $orderby_object->toSqlStatementsArray()); |
1498 | 1498 | } |
1499 | 1499 | |
1500 | - $orderby_statement = ' ORDER BY '.implode(',',$orderby_columns_array); |
|
1500 | + $orderby_statement = ' ORDER BY '.implode(',', $orderby_columns_array); |
|
1501 | 1501 | $count = 0; |
1502 | 1502 | foreach ($orderby_columns_array as $id=>$orderby_statement_phrase) { |
1503 | 1503 | // Let's remove the trailing ASC or DESC and add AS tdbm_reserved_col_Xxx |
@@ -1515,10 +1515,10 @@ discard block |
||
1515 | 1515 | $orderby_columns_array[$id] = $orderby_statement_phrase.' AS tdbm_reserved_col_'.$count; |
1516 | 1516 | $count++; |
1517 | 1517 | } |
1518 | - $orderby_column_statement = ', '.implode(',',$orderby_columns_array); |
|
1518 | + $orderby_column_statement = ', '.implode(',', $orderby_columns_array); |
|
1519 | 1519 | } |
1520 | 1520 | |
1521 | - if ($mode=="getCount") { |
|
1521 | + if ($mode == "getCount") { |
|
1522 | 1522 | // Let's get the list of primary keys to perform a DISTINCT request. |
1523 | 1523 | $pk_table = $this->getPrimaryKeyStatic($table_name); |
1524 | 1524 | |
@@ -1552,7 +1552,7 @@ discard block |
||
1552 | 1552 | if ($mode == 'explainSQL') { |
1553 | 1553 | return $sql; |
1554 | 1554 | } |
1555 | - return $this->getObjectsFromSQL($table_name, $sql, $from, $limit, $className); |
|
1555 | + return $this->getObjectsFromSQL($table_name, $sql, $from, $limit, $className); |
|
1556 | 1556 | |
1557 | 1557 | } |
1558 | 1558 | |
@@ -1577,17 +1577,17 @@ discard block |
||
1577 | 1577 | // Second, let's take all the objects out of the filter bag, and let's make filters from them |
1578 | 1578 | $filter_bag2 = array(); |
1579 | 1579 | foreach ($filter_bag as $thing) { |
1580 | - if (is_a($thing,'Mouf\\Database\\TDBM\\Filters\\FilterInterface')) { |
|
1580 | + if (is_a($thing, 'Mouf\\Database\\TDBM\\Filters\\FilterInterface')) { |
|
1581 | 1581 | $filter_bag2[] = $thing; |
1582 | 1582 | } elseif (is_string($thing)) { |
1583 | 1583 | $filter_bag2[] = new SqlStringFilter($thing); |
1584 | - } elseif (is_a($thing,'Mouf\\Database\\TDBM\\TDBMObjectArray') && count($thing)>0) { |
|
1584 | + } elseif (is_a($thing, 'Mouf\\Database\\TDBM\\TDBMObjectArray') && count($thing)>0) { |
|
1585 | 1585 | // Get table_name and column_name |
1586 | 1586 | $filter_table_name = $thing[0]->_getDbTableName(); |
1587 | 1587 | $filter_column_names = $thing[0]->getPrimaryKey(); |
1588 | 1588 | |
1589 | 1589 | // If there is only one primary key, we can use the InFilter |
1590 | - if (count($filter_column_names)==1) { |
|
1590 | + if (count($filter_column_names) == 1) { |
|
1591 | 1591 | $primary_keys_array = array(); |
1592 | 1592 | $filter_column_name = $filter_column_names[0]; |
1593 | 1593 | foreach ($thing as $TDBMObject) { |
@@ -1600,7 +1600,7 @@ discard block |
||
1600 | 1600 | { |
1601 | 1601 | $filter_bag_and = array(); |
1602 | 1602 | foreach ($thing as $TDBMObject) { |
1603 | - $filter_bag_temp_and=array(); |
|
1603 | + $filter_bag_temp_and = array(); |
|
1604 | 1604 | foreach ($filter_column_names as $pk) { |
1605 | 1605 | $filter_bag_temp_and[] = new EqualFilter($TDBMObject->_getDbTableName(), $pk, $TDBMObject->$pk); |
1606 | 1606 | } |
@@ -1610,7 +1610,7 @@ discard block |
||
1610 | 1610 | } |
1611 | 1611 | |
1612 | 1612 | |
1613 | - } elseif (!is_a($thing,'Mouf\\Database\\TDBM\\TDBMObjectArray') && $thing!==null) { |
|
1613 | + } elseif (!is_a($thing, 'Mouf\\Database\\TDBM\\TDBMObjectArray') && $thing !== null) { |
|
1614 | 1614 | 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."); |
1615 | 1615 | } |
1616 | 1616 | } |
@@ -1638,9 +1638,9 @@ discard block |
||
1638 | 1638 | // 4-2, let's take all the objects out of the orderby bag, and let's make objects from them |
1639 | 1639 | $orderby_bag2 = array(); |
1640 | 1640 | foreach ($orderby_bag as $thing) { |
1641 | - if (is_a($thing,'Mouf\\Database\\TDBM\\Filters\\OrderBySQLString')) { |
|
1641 | + if (is_a($thing, 'Mouf\\Database\\TDBM\\Filters\\OrderBySQLString')) { |
|
1642 | 1642 | $orderby_bag2[] = $thing; |
1643 | - } elseif (is_a($thing,'Mouf\\Database\\TDBM\\Filters\\OrderByColumn')) { |
|
1643 | + } elseif (is_a($thing, 'Mouf\\Database\\TDBM\\Filters\\OrderByColumn')) { |
|
1644 | 1644 | $orderby_bag2[] = $thing; |
1645 | 1645 | } elseif (is_string($thing)) { |
1646 | 1646 | $orderby_bag2[] = new OrderBySQLString($thing); |
@@ -1663,10 +1663,10 @@ discard block |
||
1663 | 1663 | $possible_tables = $this->dbConnection->checkTableExist($table); |
1664 | 1664 | if ($possible_tables !== true) |
1665 | 1665 | { |
1666 | - if (count($possible_tables)==1) |
|
1666 | + if (count($possible_tables) == 1) |
|
1667 | 1667 | $str = "Could not find table '$table'. Maybe you meant this table: '".$possible_tables[0]."'"; |
1668 | 1668 | else |
1669 | - $str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$possible_tables)."'"; |
|
1669 | + $str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '", $possible_tables)."'"; |
|
1670 | 1670 | throw new TDBMException($str); |
1671 | 1671 | } |
1672 | 1672 | } |
@@ -1689,16 +1689,16 @@ discard block |
||
1689 | 1689 | $current_node = $tree; |
1690 | 1690 | $found = true; |
1691 | 1691 | foreach ($path as $link) { |
1692 | - if ($found==true) |
|
1692 | + if ($found == true) |
|
1693 | 1693 | { |
1694 | 1694 | if (is_array($current_node->getChildren())) |
1695 | 1695 | { |
1696 | 1696 | foreach ($current_node->getChildren() as $child) |
1697 | 1697 | { |
1698 | - if ($link['table1']==$child->table_name && |
|
1699 | - $link['col1']==$child->keyNode && |
|
1700 | - $link['col2']==$child->keyParent && |
|
1701 | - $link['type']==$child->link_type) { |
|
1698 | + if ($link['table1'] == $child->table_name && |
|
1699 | + $link['col1'] == $child->keyNode && |
|
1700 | + $link['col2'] == $child->keyParent && |
|
1701 | + $link['type'] == $child->link_type) { |
|
1702 | 1702 | $current_node = $child; |
1703 | 1703 | } |
1704 | 1704 | else |
@@ -1713,7 +1713,7 @@ discard block |
||
1713 | 1713 | |
1714 | 1714 | } |
1715 | 1715 | |
1716 | - if ($found==false) |
|
1716 | + if ($found == false) |
|
1717 | 1717 | { |
1718 | 1718 | $current_node = new DisplayNode($link['table1'], $current_node, $link['type'], $link['col2'], $link['col1']); |
1719 | 1719 | } |
@@ -1738,7 +1738,7 @@ discard block |
||
1738 | 1738 | * |
1739 | 1739 | * @return string |
1740 | 1740 | */ |
1741 | - public function drawTree($tree, $x, $y, &$ret_width=0, &$ret_height=0) { |
|
1741 | + public function drawTree($tree, $x, $y, &$ret_width = 0, &$ret_height = 0) { |
|
1742 | 1742 | |
1743 | 1743 | // Let's get the background div: |
1744 | 1744 | $treeDepth = $tree->computeDepth(1)-1; |
@@ -1749,7 +1749,7 @@ discard block |
||
1749 | 1749 | |
1750 | 1750 | $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>"; |
1751 | 1751 | |
1752 | - $str .= $tree->draw(0,0, $x, $y); |
|
1752 | + $str .= $tree->draw(0, 0, $x, $y); |
|
1753 | 1753 | |
1754 | 1754 | return $str; |
1755 | 1755 | } |
@@ -1784,10 +1784,10 @@ discard block |
||
1784 | 1784 | if ($tables === true) |
1785 | 1785 | throw new TDBMException("Could not find table primary key for table '$table'. Please define a primary key for this table."); |
1786 | 1786 | elseif ($tables !== null) { |
1787 | - if (count($tables)==1) |
|
1787 | + if (count($tables) == 1) |
|
1788 | 1788 | $str = "Could not find table '$table'. Maybe you meant this table: '".$tables[0]."'"; |
1789 | 1789 | else |
1790 | - $str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '",$tables)."'"; |
|
1790 | + $str = "Could not find table '$table'. Maybe you meant one of those tables: '".implode("', '", $tables)."'"; |
|
1791 | 1791 | throw new TDBMException($str); |
1792 | 1792 | } |
1793 | 1793 | } |