@@ -133,14 +133,14 @@ |
||
133 | 133 | $work_table = explode("'", $work_str); |
134 | 134 | |
135 | 135 | if (count($work_table) == 0) |
136 | - return ''; |
|
136 | + return ''; |
|
137 | 137 | |
138 | 138 | // if we start with a ', let's remove the first text |
139 | 139 | if (strstr($work_str,"'") === 0) |
140 | - array_shift($work_table); |
|
140 | + array_shift($work_table); |
|
141 | 141 | |
142 | 142 | if (count($work_table) == 0) |
143 | - return ''; |
|
143 | + return ''; |
|
144 | 144 | |
145 | 145 | // Now, let's take only the stuff outside the quotes. |
146 | 146 | $work_str2 = ''; |
@@ -45,7 +45,7 @@ |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | private function getAllPossiblePaths() { |
48 | - return AmbiguityException::getAllPossiblePathsRec($this->paths); |
|
48 | + return AmbiguityException::getAllPossiblePathsRec($this->paths); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | private static function getAllPossiblePathsRec($sub_table_paths) |
@@ -65,9 +65,9 @@ |
||
65 | 65 | * @param string $func_name |
66 | 66 | * @param $values |
67 | 67 | * @return array|void |
68 | - * @throws TDBMException |
|
68 | + * @throws TDBMException |
|
69 | 69 | */ |
70 | - public function __call($func_name, $values) { |
|
70 | + public function __call($func_name, $values) { |
|
71 | 71 | |
72 | 72 | if (strpos($func_name,"getarray_") === 0) { |
73 | 73 | $column = substr($func_name, 9); |
@@ -170,6 +170,9 @@ |
||
170 | 170 | |
171 | 171 | protected $errorMsg; |
172 | 172 | |
173 | + /** |
|
174 | + * @param string $msg |
|
175 | + */ |
|
173 | 176 | private function displayErrorMsg($msg) { |
174 | 177 | $this->errorMsg = $msg; |
175 | 178 | $this->content->addFile(dirname(__FILE__)."/../../../../views/installError.php", $this); |
@@ -111,12 +111,12 @@ discard block |
||
111 | 111 | $this->beanNamespace = $this->moufManager->getVariable("tdbmDefaultBeanNamespace_tdbmService"); |
112 | 112 | |
113 | 113 | if ($this->daoNamespace == null && $this->beanNamespace == null) { |
114 | - $classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json'); |
|
114 | + $classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json'); |
|
115 | 115 | |
116 | - $autoloadNamespaces = $classNameMapper->getManagedNamespaces(); |
|
116 | + $autoloadNamespaces = $classNameMapper->getManagedNamespaces(); |
|
117 | 117 | if ($autoloadNamespaces) { |
118 | 118 | $this->autoloadDetected = true; |
119 | - $rootNamespace = $autoloadNamespaces[0]; |
|
119 | + $rootNamespace = $autoloadNamespaces[0]; |
|
120 | 120 | $this->daoNamespace = $rootNamespace."Dao"; |
121 | 121 | $this->beanNamespace = $rootNamespace."Dao\\Bean"; |
122 | 122 | } else { |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param string $selfedit |
147 | 147 | * @throws \Mouf\MoufException |
148 | 148 | */ |
149 | - public function generate($daonamespace, $beannamespace, $keepSupport = 0, $storeInUtc = 0, $castDatesToDateTime = 1, $selfedit="false") { |
|
149 | + public function generate($daonamespace, $beannamespace, $keepSupport = 0, $storeInUtc = 0, $castDatesToDateTime = 1, $selfedit="false") { |
|
150 | 150 | $this->selfedit = $selfedit; |
151 | 151 | |
152 | 152 | if ($selfedit == "true") { |
@@ -238,6 +238,9 @@ discard block |
||
238 | 238 | } |
239 | 239 | } |
240 | 240 | |
241 | + /** |
|
242 | + * @param string $var |
|
243 | + */ |
|
241 | 244 | public function __get($var) { |
242 | 245 | $this->_dbLoadIfNotLoaded(); |
243 | 246 | |
@@ -290,6 +293,10 @@ discard block |
||
290 | 293 | return isset($this->db_row[$var]); |
291 | 294 | } |
292 | 295 | |
296 | + /** |
|
297 | + * @param string $var |
|
298 | + * @param string|null $value |
|
299 | + */ |
|
293 | 300 | public function __set($var, $value) { |
294 | 301 | $this->_dbLoadIfNotLoaded(); |
295 | 302 | |
@@ -642,7 +649,7 @@ discard block |
||
642 | 649 | /** |
643 | 650 | * Returns the tables used in the filter in an array. |
644 | 651 | * |
645 | - * @return array<string> |
|
652 | + * @return string[] |
|
646 | 653 | */ |
647 | 654 | public function getUsedTables() { |
648 | 655 | return array($this->db_table_name); |
@@ -170,26 +170,26 @@ discard block |
||
170 | 170 | $this->TDBMObject_state = $state; |
171 | 171 | } |
172 | 172 | |
173 | - /** |
|
174 | - * Internal TDBM method, you should not use this. |
|
175 | - * Loads the db_row property of the object from the $row array. |
|
176 | - * Any row having a key starting with 'tdbm_reserved_col_' is ignored. |
|
177 | - * |
|
178 | - * @param array $row |
|
179 | - * @param array|null $colsArray A big optimization to avoid calling strpos to many times. This array should |
|
180 | - * contain as keys the list of interesting columns. If null, this list will be initialized. |
|
181 | - */ |
|
173 | + /** |
|
174 | + * Internal TDBM method, you should not use this. |
|
175 | + * Loads the db_row property of the object from the $row array. |
|
176 | + * Any row having a key starting with 'tdbm_reserved_col_' is ignored. |
|
177 | + * |
|
178 | + * @param array $row |
|
179 | + * @param array|null $colsArray A big optimization to avoid calling strpos to many times. This array should |
|
180 | + * contain as keys the list of interesting columns. If null, this list will be initialized. |
|
181 | + */ |
|
182 | 182 | public function loadFromRow($row, &$colsArray) { |
183 | - if ($colsArray === null) { |
|
184 | - foreach ($row as $key=>$value) { |
|
185 | - if (strpos($key, 'tdbm_reserved_col_')!==0) { |
|
186 | - $colsArray[$key] = true; |
|
187 | - } |
|
188 | - } |
|
189 | - } |
|
190 | - |
|
191 | - $this->db_row = array_intersect_key($row, $colsArray); |
|
192 | - $this->TDBMObject_state = "loaded"; |
|
183 | + if ($colsArray === null) { |
|
184 | + foreach ($row as $key=>$value) { |
|
185 | + if (strpos($key, 'tdbm_reserved_col_')!==0) { |
|
186 | + $colsArray[$key] = true; |
|
187 | + } |
|
188 | + } |
|
189 | + } |
|
190 | + |
|
191 | + $this->db_row = array_intersect_key($row, $colsArray); |
|
192 | + $this->TDBMObject_state = "loaded"; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -325,9 +325,9 @@ discard block |
||
325 | 325 | |
326 | 326 | /** |
327 | 327 | * Saves the current object by INSERTing or UPDAT(E)ing it in the database. |
328 | - * |
|
329 | - * This method must be called only from the DAOs. |
|
330 | - * @internal |
|
328 | + * |
|
329 | + * This method must be called only from the DAOs. |
|
330 | + * @internal |
|
331 | 331 | */ |
332 | 332 | public function save() { |
333 | 333 | if (!is_array($this->db_row)) { |
@@ -510,10 +510,10 @@ discard block |
||
510 | 510 | * |
511 | 511 | * @param string $func_name |
512 | 512 | * @param $values |
513 | - * @return TDBMObjectArray A TDBMObjectArray containing the resulting objects of the query. |
|
514 | - * @throws TDBMException |
|
513 | + * @return TDBMObjectArray A TDBMObjectArray containing the resulting objects of the query. |
|
514 | + * @throws TDBMException |
|
515 | 515 | */ |
516 | - public function __call($func_name, $values) { |
|
516 | + public function __call($func_name, $values) { |
|
517 | 517 | |
518 | 518 | if (strpos($func_name,"get_") === 0) { |
519 | 519 | $table = substr($func_name,4); |
@@ -548,48 +548,48 @@ discard block |
||
548 | 548 | } |
549 | 549 | |
550 | 550 | /** |
551 | - * Implements array behaviour for our object. |
|
552 | - * |
|
553 | - * @param string $offset |
|
554 | - * @param string $value |
|
555 | - */ |
|
551 | + * Implements array behaviour for our object. |
|
552 | + * |
|
553 | + * @param string $offset |
|
554 | + * @param string $value |
|
555 | + */ |
|
556 | 556 | public function offsetSet($offset, $value) { |
557 | 557 | $this->__set($offset, $value); |
558 | - } |
|
558 | + } |
|
559 | 559 | /** |
560 | 560 | * Implements array behaviour for our object. |
561 | 561 | * |
562 | 562 | * @param string $offset |
563 | - * @return bool |
|
563 | + * @return bool |
|
564 | 564 | */ |
565 | - public function offsetExists($offset) { |
|
566 | - $this->_dbLoadIfNotLoaded(); |
|
567 | - return isset($this->db_row[$offset]); |
|
568 | - } |
|
565 | + public function offsetExists($offset) { |
|
566 | + $this->_dbLoadIfNotLoaded(); |
|
567 | + return isset($this->db_row[$offset]); |
|
568 | + } |
|
569 | 569 | /** |
570 | 570 | * Implements array behaviour for our object. |
571 | 571 | * |
572 | 572 | * @param string $offset |
573 | 573 | */ |
574 | - public function offsetUnset($offset) { |
|
574 | + public function offsetUnset($offset) { |
|
575 | 575 | $this->__set($offset, null); |
576 | - } |
|
576 | + } |
|
577 | 577 | /** |
578 | 578 | * Implements array behaviour for our object. |
579 | 579 | * |
580 | 580 | * @param string $offset |
581 | - * @return mixed|null |
|
581 | + * @return mixed|null |
|
582 | 582 | */ |
583 | - public function offsetGet($offset) { |
|
584 | - return $this->__get($offset); |
|
585 | - } |
|
583 | + public function offsetGet($offset) { |
|
584 | + return $this->__get($offset); |
|
585 | + } |
|
586 | 586 | |
587 | 587 | private $_validIterator = false; |
588 | 588 | /** |
589 | 589 | * Implements iterator behaviour for our object (so we can each column). |
590 | 590 | */ |
591 | 591 | public function rewind() { |
592 | - $this->_dbLoadIfNotLoaded(); |
|
592 | + $this->_dbLoadIfNotLoaded(); |
|
593 | 593 | if (count($this->db_row)>0) { |
594 | 594 | $this->_validIterator = true; |
595 | 595 | } else { |
@@ -677,21 +677,21 @@ discard block |
||
677 | 677 | return $sql_where; |
678 | 678 | } |
679 | 679 | |
680 | - /** |
|
681 | - * Override the native php clone function for TDBMObjects |
|
682 | - */ |
|
683 | - public function __clone(){ |
|
684 | - $this->_dbLoadIfNotLoaded(); |
|
685 | - //First lets set the status to new (to enter the save function) |
|
686 | - $this->TDBMObject_state = "new"; |
|
687 | - |
|
688 | - // Add the current TDBMObject to the save object list |
|
689 | - $this->tdbmService->_addToToSaveObjectList($this); |
|
690 | - |
|
691 | - //Now unset the PK from the row |
|
692 | - $pk_array = $this->getPrimaryKey(); |
|
693 | - foreach ($pk_array as $pk) { |
|
694 | - $this->db_row[$pk] = null; |
|
695 | - } |
|
696 | - } |
|
680 | + /** |
|
681 | + * Override the native php clone function for TDBMObjects |
|
682 | + */ |
|
683 | + public function __clone(){ |
|
684 | + $this->_dbLoadIfNotLoaded(); |
|
685 | + //First lets set the status to new (to enter the save function) |
|
686 | + $this->TDBMObject_state = "new"; |
|
687 | + |
|
688 | + // Add the current TDBMObject to the save object list |
|
689 | + $this->tdbmService->_addToToSaveObjectList($this); |
|
690 | + |
|
691 | + //Now unset the PK from the row |
|
692 | + $pk_array = $this->getPrimaryKey(); |
|
693 | + foreach ($pk_array as $pk) { |
|
694 | + $this->db_row[$pk] = null; |
|
695 | + } |
|
696 | + } |
|
697 | 697 | } |
698 | 698 | \ No newline at end of file |
@@ -166,7 +166,7 @@ |
||
166 | 166 | } |
167 | 167 | /** |
168 | 168 | * Returns the current result's _id |
169 | - * @return string The current result's _id as a string. |
|
169 | + * @return integer The current result's _id as a string. |
|
170 | 170 | */ |
171 | 171 | public function key() |
172 | 172 | { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | protected $current = false; |
57 | 57 | |
58 | - private $colsArray = null; |
|
58 | + private $colsArray = null; |
|
59 | 59 | |
60 | 60 | public function __construct(\PDOStatement $pdoStatement, ConnectionInterface $dbConnection, $primary_keys, $table_name, $objectStorage, $className, TDBMService $tdbmService, $sql) |
61 | 61 | { |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | * Casts a document to a new instance specified in the $recordClass |
74 | 74 | * @param array $fullCaseRow |
75 | 75 | * @return Record_Abstract|false |
76 | - * @throws TDBMException |
|
76 | + * @throws TDBMException |
|
77 | 77 | */ |
78 | - protected function cast($fullCaseRow) |
|
78 | + protected function cast($fullCaseRow) |
|
79 | 79 | { |
80 | 80 | if (!is_array($fullCaseRow)) { |
81 | 81 | return false; |
@@ -711,10 +711,10 @@ discard block |
||
711 | 711 | |
712 | 712 | /** |
713 | 713 | * Returns a generator for the database. |
714 | - * @param unknown $result |
|
714 | + * @param \PDOStatement $result |
|
715 | 715 | * @param unknown $table_name |
716 | - * @param unknown $className |
|
717 | - * @param unknown $sql |
|
716 | + * @param string $className |
|
717 | + * @param string $sql |
|
718 | 718 | */ |
719 | 719 | private function getObjectsFromSQLGenerator($result, $table_name, $className, $sql) { |
720 | 720 | $keysStandardCased = array(); |
@@ -1100,7 +1100,7 @@ discard block |
||
1100 | 1100 | * @param unknown_type $target_tables |
1101 | 1101 | * @param unknown_type $path |
1102 | 1102 | * @param unknown_type $queue |
1103 | - * @return unknown |
|
1103 | + * @return boolean |
|
1104 | 1104 | */ |
1105 | 1105 | private function find_paths_iter(&$target_tables, &$path, &$queue) { |
1106 | 1106 | // Get table to look at: |
@@ -1569,7 +1569,7 @@ discard block |
||
1569 | 1569 | * Takes in input a filter_bag (which can be about anything from a string to an array of TDBMObjects... see above from documentation), |
1570 | 1570 | * and gives back a proper Filter object. |
1571 | 1571 | * |
1572 | - * @param unknown_type $filter_bag |
|
1572 | + * @param unknown_type|null $filter_bag |
|
1573 | 1573 | * @return FilterInterface |
1574 | 1574 | */ |
1575 | 1575 | public function buildFilterFromFilterBag($filter_bag) { |
@@ -1634,7 +1634,7 @@ discard block |
||
1634 | 1634 | * Takes in input an order_bag (which can be about anything from a string to an array of OrderByColumn objects... see above from documentation), |
1635 | 1635 | * and gives back an array of OrderByColumn / OrderBySQLString objects. |
1636 | 1636 | * |
1637 | - * @param unknown_type $orderby_bag |
|
1637 | + * @param unknown_type|null $orderby_bag |
|
1638 | 1638 | * @return array |
1639 | 1639 | */ |
1640 | 1640 | public function buildOrderArrayFromOrderBag($orderby_bag) { |
@@ -1851,7 +1851,7 @@ discard block |
||
1851 | 1851 | * @param bool $support If the generated daos should keep support for old functions (eg : getUserList and getList) |
1852 | 1852 | * @param bool $storeInUtc If the generated daos should store the date in UTC timezone instead of user's timezone. |
1853 | 1853 | * @param bool $castDatesToDateTime |
1854 | - * @return \string[] the list of tables |
|
1854 | + * @return string[] the list of tables |
|
1855 | 1855 | */ |
1856 | 1856 | public function generateAllDaosAndBeans($daoFactoryClassName, $daonamespace, $beannamespace, $support, $storeInUtc, $castDatesToDateTime) { |
1857 | 1857 | $tdbmDaoGenerator = new TDBMDaoGenerator($this->dbConnection); |
@@ -545,45 +545,45 @@ discard block |
||
545 | 545 | } |
546 | 546 | } |
547 | 547 | |
548 | - /** |
|
549 | - * This function removes the given object from the database. It will also remove all objects relied to the one given |
|
550 | - * by parameter before all. |
|
551 | - * |
|
552 | - * Notice: if the object has a multiple primary key, the function will not work. |
|
553 | - * |
|
554 | - * @param TDBMObject $objToDelete |
|
555 | - */ |
|
556 | - public function deleteCascade(TDBMObject $objToDelete) { |
|
557 | - $this->deleteAllConstraintWithThisObject($objToDelete); |
|
558 | - $this->deleteObject($objToDelete); |
|
559 | - } |
|
560 | - |
|
561 | - /** |
|
562 | - * This function is used only in TDBMService (private function) |
|
563 | - * It will call deleteCascade function foreach object relied with a foreign key to the object given by parameter |
|
564 | - * |
|
565 | - * @param TDBMObject $obj |
|
566 | - * @return TDBMObjectArray |
|
567 | - */ |
|
568 | - private function deleteAllConstraintWithThisObject(TDBMObject $obj) { |
|
569 | - $tableFrom = $this->dbConnection->escapeDBItem($obj->_getDbTableName()); |
|
570 | - $constraints = $this->dbConnection->getConstraintsFromTable($tableFrom); |
|
571 | - foreach ($constraints as $constraint) { |
|
572 | - $tableTo = $this->dbConnection->escapeDBItem($constraint["table1"]); |
|
573 | - $colFrom = $this->dbConnection->escapeDBItem($constraint["col2"]); |
|
574 | - $colTo = $this->dbConnection->escapeDBItem($constraint["col1"]); |
|
575 | - $idVarName = $this->dbConnection->escapeDBItem($obj->getPrimaryKey()[0]); |
|
576 | - $idValue = $this->dbConnection->quoteSmart($obj->TDBMObject_id); |
|
577 | - $sql = "SELECT DISTINCT ".$tableTo.".*" |
|
578 | - ." FROM ".$tableFrom |
|
579 | - ." LEFT JOIN ".$tableTo." ON ".$tableFrom.".".$colFrom." = ".$tableTo.".".$colTo |
|
580 | - ." WHERE ".$tableFrom.".".$idVarName."=".$idValue; |
|
581 | - $result = $this->getObjectsFromSQL($constraint["table1"], $sql); |
|
582 | - foreach ($result as $tdbmObj) { |
|
583 | - $this->deleteCascade($tdbmObj); |
|
584 | - } |
|
585 | - } |
|
586 | - } |
|
548 | + /** |
|
549 | + * This function removes the given object from the database. It will also remove all objects relied to the one given |
|
550 | + * by parameter before all. |
|
551 | + * |
|
552 | + * Notice: if the object has a multiple primary key, the function will not work. |
|
553 | + * |
|
554 | + * @param TDBMObject $objToDelete |
|
555 | + */ |
|
556 | + public function deleteCascade(TDBMObject $objToDelete) { |
|
557 | + $this->deleteAllConstraintWithThisObject($objToDelete); |
|
558 | + $this->deleteObject($objToDelete); |
|
559 | + } |
|
560 | + |
|
561 | + /** |
|
562 | + * This function is used only in TDBMService (private function) |
|
563 | + * It will call deleteCascade function foreach object relied with a foreign key to the object given by parameter |
|
564 | + * |
|
565 | + * @param TDBMObject $obj |
|
566 | + * @return TDBMObjectArray |
|
567 | + */ |
|
568 | + private function deleteAllConstraintWithThisObject(TDBMObject $obj) { |
|
569 | + $tableFrom = $this->dbConnection->escapeDBItem($obj->_getDbTableName()); |
|
570 | + $constraints = $this->dbConnection->getConstraintsFromTable($tableFrom); |
|
571 | + foreach ($constraints as $constraint) { |
|
572 | + $tableTo = $this->dbConnection->escapeDBItem($constraint["table1"]); |
|
573 | + $colFrom = $this->dbConnection->escapeDBItem($constraint["col2"]); |
|
574 | + $colTo = $this->dbConnection->escapeDBItem($constraint["col1"]); |
|
575 | + $idVarName = $this->dbConnection->escapeDBItem($obj->getPrimaryKey()[0]); |
|
576 | + $idValue = $this->dbConnection->quoteSmart($obj->TDBMObject_id); |
|
577 | + $sql = "SELECT DISTINCT ".$tableTo.".*" |
|
578 | + ." FROM ".$tableFrom |
|
579 | + ." LEFT JOIN ".$tableTo." ON ".$tableFrom.".".$colFrom." = ".$tableTo.".".$colTo |
|
580 | + ." WHERE ".$tableFrom.".".$idVarName."=".$idValue; |
|
581 | + $result = $this->getObjectsFromSQL($constraint["table1"], $sql); |
|
582 | + foreach ($result as $tdbmObj) { |
|
583 | + $this->deleteCascade($tdbmObj); |
|
584 | + } |
|
585 | + } |
|
586 | + } |
|
587 | 587 | |
588 | 588 | /** |
589 | 589 | * The getObjectsFromSQL is used to retrieve objects from the database using a full SQL query. |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | } |
645 | 645 | $keysStandardCased = array(); |
646 | 646 | $firstLine = true; |
647 | - $colsArray = null; |
|
647 | + $colsArray = null; |
|
648 | 648 | while ($fullCaseRow = $result->fetch(\PDO::FETCH_ASSOC)) |
649 | 649 | { |
650 | 650 | $row = array(); |
@@ -676,17 +676,17 @@ discard block |
||
676 | 676 | $id = serialize($ids); |
677 | 677 | } |
678 | 678 | |
679 | - $obj = $this->objectStorage->get($table_name,$id); |
|
679 | + $obj = $this->objectStorage->get($table_name,$id); |
|
680 | 680 | if ($obj === null) |
681 | 681 | { |
682 | 682 | if (!is_a($className, "Mouf\\Database\\TDBM\\TDBMObject", true)) { |
683 | 683 | throw new TDBMException("Error while calling TDBM: The class ".$className." should extend TDBMObject."); |
684 | 684 | } |
685 | 685 | $obj = new $className($this, $table_name, $id); |
686 | - $obj->loadFromRow($row, $colsArray); |
|
687 | - $this->objectStorage->set($table_name, $id, $obj); |
|
686 | + $obj->loadFromRow($row, $colsArray); |
|
687 | + $this->objectStorage->set($table_name, $id, $obj); |
|
688 | 688 | } elseif ($obj->_getStatus() == "not loaded") { |
689 | - $obj->loadFromRow($row, $colsArray); |
|
689 | + $obj->loadFromRow($row, $colsArray); |
|
690 | 690 | // Check that the object fetched from cache is from the requested class. |
691 | 691 | if (!is_a($obj, $className)) { |
692 | 692 | 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($obj)."."); |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | private function getObjectsFromSQLGenerator($result, $table_name, $className, $sql) { |
720 | 720 | $keysStandardCased = array(); |
721 | 721 | $firstLine = true; |
722 | - $colsArray = null; |
|
722 | + $colsArray = null; |
|
723 | 723 | while ($fullCaseRow = $result->fetch(\PDO::FETCH_ASSOC)) |
724 | 724 | { |
725 | 725 | $row = array(); |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | } |
751 | 751 | $id = serialize($ids); |
752 | 752 | } |
753 | - $obj = $this->objectStorage->get($table_name, $id); |
|
753 | + $obj = $this->objectStorage->get($table_name, $id); |
|
754 | 754 | if ($obj === null) |
755 | 755 | { |
756 | 756 | if ($className == null) { |
@@ -763,10 +763,10 @@ discard block |
||
763 | 763 | } else { |
764 | 764 | throw new TDBMException("Error while casting TDBMObject to class, the parameter passed is not a string. Value passed: ".$className); |
765 | 765 | } |
766 | - $obj->loadFromRow($row, $colsArray); |
|
767 | - $this->objectStorage->set($table_name, $id, $obj); |
|
766 | + $obj->loadFromRow($row, $colsArray); |
|
767 | + $this->objectStorage->set($table_name, $id, $obj); |
|
768 | 768 | } elseif ($obj->_getStatus() == "not loaded") { |
769 | - $obj->loadFromRow($row, $colsArray); |
|
769 | + $obj->loadFromRow($row, $colsArray); |
|
770 | 770 | // Check that the object fetched from cache is from the requested class. |
771 | 771 | if ($className != null) { |
772 | 772 | if (!is_subclass_of(get_class($obj), $className) && get_class($obj) != $className) { |
@@ -1466,33 +1466,33 @@ discard block |
||
1466 | 1466 | } |
1467 | 1467 | |
1468 | 1468 | //If no $hint_path is provided, check that a path exists |
1469 | - if($hint_path === null){ |
|
1470 | - // Now, for each needed table to perform the order by, we must verify if the relationship between the order by and the object is indeed a 1* relationship |
|
1471 | - foreach ($needed_table_array_for_orderby as $target_table_table) { |
|
1472 | - // Get the path between the main table and the target group by table |
|
1469 | + if($hint_path === null){ |
|
1470 | + // Now, for each needed table to perform the order by, we must verify if the relationship between the order by and the object is indeed a 1* relationship |
|
1471 | + foreach ($needed_table_array_for_orderby as $target_table_table) { |
|
1472 | + // Get the path between the main table and the target group by table |
|
1473 | 1473 | |
1474 | - // TODO! Pas bon!!!! Faut le quérir, hélas! |
|
1475 | - // Mais comment gérer ça sans plomber les perfs et en utilisant le path fourni????? |
|
1474 | + // TODO! Pas bon!!!! Faut le quérir, hélas! |
|
1475 | + // Mais comment gérer ça sans plomber les perfs et en utilisant le path fourni????? |
|
1476 | 1476 | |
1477 | - $path = $this->getPathFromCache($table_name, $target_table_table); |
|
1477 | + $path = $this->getPathFromCache($table_name, $target_table_table); |
|
1478 | 1478 | |
1479 | - /********************************** |
|
1479 | + /********************************** |
|
1480 | 1480 | * Modifier par Marc de *1 vers 1* |
1481 | 1481 | * (sur les conseils de David !) |
1482 | 1482 | */ |
1483 | - $is_ok = true; |
|
1484 | - foreach ($path as $step) { |
|
1485 | - if ($step["type"]=="1*") { |
|
1486 | - $is_ok = false; |
|
1487 | - break; |
|
1488 | - } |
|
1489 | - } |
|
1490 | - |
|
1491 | - if (!$is_ok) { |
|
1492 | - throw new TDBMException("Error in querying database from getObjectsByFilter. You tried to order your data according to a column of the '$target_table_table' table. However, the '$target_table_table' table has a many to 1 relationship with the '$table_name' table. This means that one '$table_name' object can contain many '$target_table_table' objects. Therefore, trying to order '$table_name' objects using '$target_table_table' objects is meaningless and cannot be performed."); |
|
1493 | - } |
|
1494 | - } |
|
1495 | - } |
|
1483 | + $is_ok = true; |
|
1484 | + foreach ($path as $step) { |
|
1485 | + if ($step["type"]=="1*") { |
|
1486 | + $is_ok = false; |
|
1487 | + break; |
|
1488 | + } |
|
1489 | + } |
|
1490 | + |
|
1491 | + if (!$is_ok) { |
|
1492 | + throw new TDBMException("Error in querying database from getObjectsByFilter. You tried to order your data according to a column of the '$target_table_table' table. However, the '$target_table_table' table has a many to 1 relationship with the '$table_name' table. This means that one '$table_name' object can contain many '$target_table_table' objects. Therefore, trying to order '$table_name' objects using '$target_table_table' objects is meaningless and cannot be performed."); |
|
1493 | + } |
|
1494 | + } |
|
1495 | + } |
|
1496 | 1496 | |
1497 | 1497 | // In a SELECT DISTINCT ... ORDER BY ... clause, the orderbyed columns must appear! |
1498 | 1498 | // Therefore, we must be able to parse the Orderby columns requested, give them dummy names and remove them afterward! |
@@ -1667,9 +1667,9 @@ discard block |
||
1667 | 1667 | * Throws a TDBMException if one of those table does not exist. |
1668 | 1668 | * |
1669 | 1669 | * @param array $tables |
1670 | - * @throws TDBMException |
|
1670 | + * @throws TDBMException |
|
1671 | 1671 | */ |
1672 | - private function checkTablesExist($tables) { |
|
1672 | + private function checkTablesExist($tables) { |
|
1673 | 1673 | foreach ($tables as $table) { |
1674 | 1674 | $possible_tables = $this->dbConnection->checkTableExist($table); |
1675 | 1675 | if ($possible_tables !== true) |
@@ -1742,12 +1742,12 @@ discard block |
||
1742 | 1742 | * This function returns the HTML to draw a tree of DisplayNode. |
1743 | 1743 | * |
1744 | 1744 | * @param DisplayNode $tree |
1745 | - * @param int $x |
|
1746 | - * @param int $y |
|
1747 | - * @param int $ret_width |
|
1748 | - * @param int $ret_height |
|
1749 | - * |
|
1750 | - * @return string |
|
1745 | + * @param int $x |
|
1746 | + * @param int $y |
|
1747 | + * @param int $ret_width |
|
1748 | + * @param int $ret_height |
|
1749 | + * |
|
1750 | + * @return string |
|
1751 | 1751 | */ |
1752 | 1752 | public function drawTree($tree, $x, $y, &$ret_width=0, &$ret_height=0) { |
1753 | 1753 | |
@@ -1861,8 +1861,8 @@ discard block |
||
1861 | 1861 | } |
1862 | 1862 | |
1863 | 1863 | /** |
1864 | - * @param array<string, string> $tableToBeanMap |
|
1865 | - */ |
|
1864 | + * @param array<string, string> $tableToBeanMap |
|
1865 | + */ |
|
1866 | 1866 | public function setTableToBeanMap(array $tableToBeanMap) { |
1867 | 1867 | $this->tableToBeanMap = $tableToBeanMap; |
1868 | 1868 | } |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | if ($this->daoNamespace == null && $this->beanNamespace == null) { |
68 | - $classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json'); |
|
68 | + $classNameMapper = ClassNameMapper::createFromComposerFile(__DIR__.'/../../../../../../../../composer.json'); |
|
69 | 69 | |
70 | 70 | $autoloadNamespaces = $classNameMapper->getManagedNamespaces(); |
71 | - if ($autoloadNamespaces) { |
|
71 | + if ($autoloadNamespaces) { |
|
72 | 72 | $this->autoloadDetected = true; |
73 | 73 | $rootNamespace = $autoloadNamespaces[0]; |
74 | 74 | $this->daoNamespace = $rootNamespace."Dao"; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | $tdbmService = new InstanceProxy($name); |
152 | 152 | /* @var $tdbmService TDBMService */ |
153 | - $tables = $tdbmService->generateAllDaosAndBeans($daofactoryclassname, $daonamespace, $beannamespace, $keepSupport, $storeInUtc, $castDatesToDateTime); |
|
153 | + $tables = $tdbmService->generateAllDaosAndBeans($daofactoryclassname, $daonamespace, $beannamespace, $keepSupport, $storeInUtc, $castDatesToDateTime); |
|
154 | 154 | |
155 | 155 | |
156 | 156 | $moufManager->declareComponent($daofactoryinstancename, $daonamespace."\\".$daofactoryclassname, false, MoufManager::DECLARE_ON_EXIST_KEEP_INCOMING_LINKS); |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @param string $tableName |
100 | 100 | * @param string $columnName |
101 | - * @param string $value1 |
|
102 | - * @param string $value2 |
|
101 | + * @param string $value1 |
|
102 | + * @param string $value2 |
|
103 | 103 | */ |
104 | 104 | public function __construct($tableName=null, $columnName=null, $value1=null, $value2=null) { |
105 | 105 | $this->tableName = $tableName; |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @param ConnectionInterface $dbConnection |
115 | 115 | * @return string |
116 | - * @throws \Mouf\Database\TDBM\TDBMException |
|
116 | + * @throws \Mouf\Database\TDBM\TDBMException |
|
117 | 117 | */ |
118 | - public function toSql(ConnectionInterface $dbConnection) { |
|
118 | + public function toSql(ConnectionInterface $dbConnection) { |
|
119 | 119 | if ($this->enableCondition != null && !$this->enableCondition->isOk()) { |
120 | 120 | return ""; |
121 | 121 | } |