1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| public static function isComponentInQuery($component, $query) {
foreach($query->getQueryComponents() as $alias => $compo)
if($compo['table']->getComponentName() == $component)
return true;
return array_search($component, $query->getTableAliasMap());
}
public static function proceedAliasDefinition(Doctrine_Query $query, $modelsTab, $doublonsAccepted=null) {
foreach($modelsTab as $component) {
$alias = self::genStr();
if(!class_exists($component))
throw new Exception("Le composant " . $component . " n'existe pas !");
if(!rorTools::isComponentInQuery($component, $query) || (rorTools::isComponentInQuery($component, $query) && $doublonsAccepted)) {
$table_alias = $query->generateNewSqlTableAlias($alias, $component);
$query->addSqlTableAlias($table_alias, $alias);
$aliasTab[$component] = $table_alias;
} else {
$method = $component . 'Table';
$aliasTab[$component] = $query->getSqlTableAlias($component, $method::getInstance()->getTableName());
}
} |
Partager