@@ -2,12 +2,8 @@ |
||
2 | 2 | namespace Mouf\Database\TDBM\Controllers; |
3 | 3 | |
4 | 4 | use Mouf\Composer\ClassNameMapper; |
5 | -use Mouf\MoufUtils; |
|
6 | - |
|
7 | 5 | use Mouf\Actions\InstallUtils; |
8 | - |
|
9 | 6 | use Mouf\MoufManager; |
10 | - |
|
11 | 7 | use Mouf\Html\HtmlElement\HtmlBlock; |
12 | 8 | use Mouf\Mvc\Splash\Controllers\Controller; |
13 | 9 |
@@ -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") { |
@@ -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 = ''; |
@@ -1,8 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Mouf\Database\TDBM\Filters; |
3 | 3 | |
4 | -use Mouf\Database\DBConnection\ConnectionInterface; |
|
5 | - |
|
6 | 4 | /* |
7 | 5 | Copyright (C) 2006-2011 David Négrier - THE CODING MACHINE |
8 | 6 |
@@ -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); |
@@ -28,7 +28,6 @@ |
||
28 | 28 | use Mouf\Utils\Cache\CacheInterface; |
29 | 29 | use Mouf\Database\TDBM\Filters\FilterInterface; |
30 | 30 | use Mouf\Database\DBConnection\ConnectionInterface; |
31 | -use Mouf\Database\DBConnection\DBConnectionException; |
|
32 | 31 | use Mouf\Database\TDBM\Filters\OrFilter; |
33 | 32 | use Mouf\Database\TDBM\Utils\TDBMDaoGenerator; |
34 | 33 |
@@ -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 | } |
@@ -9,14 +9,14 @@ |
||
9 | 9 | */ |
10 | 10 | class FilterUtils |
11 | 11 | { |
12 | - /** |
|
13 | - * @param string|null|DateTimeInterface $value |
|
14 | - */ |
|
15 | - public static function valueToSql($value, ConnectionInterface $dbConnection) { |
|
16 | - if ($value instanceof DateTimeInterface) { |
|
17 | - return "'".$value->format('Y-m-d H:i:s')."'"; |
|
18 | - } else { |
|
19 | - return $dbConnection->quoteSmart($value); |
|
20 | - } |
|
21 | - } |
|
12 | + /** |
|
13 | + * @param string|null|DateTimeInterface $value |
|
14 | + */ |
|
15 | + public static function valueToSql($value, ConnectionInterface $dbConnection) { |
|
16 | + if ($value instanceof DateTimeInterface) { |
|
17 | + return "'".$value->format('Y-m-d H:i:s')."'"; |
|
18 | + } else { |
|
19 | + return $dbConnection->quoteSmart($value); |
|
20 | + } |
|
21 | + } |
|
22 | 22 | } |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @param ConnectionInterface $dbConnection |
70 | 70 | * @return string |
71 | - * @throws TDBMException |
|
71 | + * @throws TDBMException |
|
72 | 72 | */ |
73 | - public function toSql(ConnectionInterface $dbConnection) { |
|
73 | + public function toSql(ConnectionInterface $dbConnection) { |
|
74 | 74 | if ($this->enableCondition != null && !$this->enableCondition->isOk()) { |
75 | 75 | return ""; |
76 | 76 | } |
@@ -102,22 +102,22 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return array<string> |
104 | 104 | */ |
105 | - public function getUsedTables() { |
|
106 | - if ($this->enableCondition != null && !$this->enableCondition->isOk()) { |
|
107 | - return array(); |
|
108 | - } |
|
109 | - |
|
110 | - $tables = array(); |
|
111 | - foreach ($this->filters as $filter) { |
|
112 | - |
|
113 | - if (!$filter instanceof FilterInterface) { |
|
114 | - throw new TDBMException("Error in OrFilter: One of the parameters is not a filter."); |
|
115 | - } |
|
116 | - |
|
117 | - $tables = array_merge($tables,$filter->getUsedTables()); |
|
118 | - } |
|
119 | - // Remove tables in double. |
|
120 | - $tables = array_flip(array_flip($tables)); |
|
121 | - return $tables; |
|
122 | - } |
|
105 | + public function getUsedTables() { |
|
106 | + if ($this->enableCondition != null && !$this->enableCondition->isOk()) { |
|
107 | + return array(); |
|
108 | + } |
|
109 | + |
|
110 | + $tables = array(); |
|
111 | + foreach ($this->filters as $filter) { |
|
112 | + |
|
113 | + if (!$filter instanceof FilterInterface) { |
|
114 | + throw new TDBMException("Error in OrFilter: One of the parameters is not a filter."); |
|
115 | + } |
|
116 | + |
|
117 | + $tables = array_merge($tables,$filter->getUsedTables()); |
|
118 | + } |
|
119 | + // Remove tables in double. |
|
120 | + $tables = array_flip(array_flip($tables)); |
|
121 | + return $tables; |
|
122 | + } |
|
123 | 123 | } |