This commit is contained in:
parent
2ce1c5f483
commit
b6dcef0eee
@ -189,16 +189,32 @@ class Doctrine_Hydrate
|
||||
|
||||
return $alias;
|
||||
}
|
||||
/**
|
||||
* getAliases
|
||||
* returns all aliases
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAliases()
|
||||
{
|
||||
return $this->shortAliases;
|
||||
}
|
||||
public function addAlias($tableAlias, $componentAlias)
|
||||
/**
|
||||
* addTableAlias
|
||||
* adds an alias for table and associates it with given component alias
|
||||
*
|
||||
* @param string $componentAlias the alias for the query component associated with given tableAlias
|
||||
* @param string $tableAlias the table alias to be added
|
||||
* @return Doctrine_Hydrate
|
||||
*/
|
||||
public function addTableAlias($tableAlias, $componentAlias)
|
||||
{
|
||||
$this->shortAliases[$tableAlias] = $componentAlias;
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* getShortAlias
|
||||
* getTableAlias
|
||||
* some database such as Oracle need the identifier lengths to be < ~30 chars
|
||||
* hence Doctrine creates as short identifier aliases as possible
|
||||
*
|
||||
@ -209,7 +225,7 @@ class Doctrine_Hydrate
|
||||
* @param string $tableName the table name from which the table alias is being created
|
||||
* @return string the generated / fetched short alias
|
||||
*/
|
||||
public function getShortAlias($componentAlias, $tableName = null)
|
||||
public function getTableAlias($componentAlias, $tableName = null)
|
||||
{
|
||||
$alias = array_search($componentAlias, $this->shortAliases);
|
||||
|
||||
@ -223,17 +239,23 @@ class Doctrine_Hydrate
|
||||
|
||||
return $this->generateShortAlias($componentAlias, $tableName);
|
||||
}
|
||||
|
||||
public function getTableAlias($componentAlias)
|
||||
{
|
||||
return $this->getShortAlias($componentAlias);
|
||||
}
|
||||
/**
|
||||
* addQueryPart
|
||||
* adds a query part in the query part array
|
||||
*
|
||||
* @param string $name the name of the query part to be added
|
||||
* @param string $part query part string
|
||||
* @throws Doctrine_Hydrate_Exception if trying to add unknown query part
|
||||
* @return Doctrine_Hydrate this object
|
||||
*/
|
||||
public function addQueryPart($name, $part)
|
||||
{
|
||||
if ( ! isset($this->parts[$name])) {
|
||||
throw new Doctrine_Hydrate_Exception('Unknown query part ' . $name);
|
||||
}
|
||||
$this->parts[$name][] = $part;
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function getDeclaration($name)
|
||||
{
|
||||
@ -243,6 +265,15 @@ class Doctrine_Hydrate
|
||||
|
||||
return $this->_aliasMap[$name];
|
||||
}
|
||||
/**
|
||||
* setQueryPart
|
||||
* sets a query part in the query part array
|
||||
*
|
||||
* @param string $name the name of the query part to be set
|
||||
* @param string $part query part string
|
||||
* @throws Doctrine_Hydrate_Exception if trying to set unknown query part
|
||||
* @return Doctrine_Hydrate this object
|
||||
*/
|
||||
public function setQueryPart($name, $part)
|
||||
{
|
||||
if ( ! isset($this->parts[$name])) {
|
||||
@ -254,6 +285,8 @@ class Doctrine_Hydrate
|
||||
} else {
|
||||
$this->parts[$name] = $part;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* copyAliases
|
||||
|
@ -653,7 +653,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
||||
break;
|
||||
}
|
||||
|
||||
$field = $this->getShortAlias($rootAlias) . '.' . $table->getIdentifier();
|
||||
$field = $this->getTableAlias($rootAlias) . '.' . $table->getIdentifier();
|
||||
|
||||
// only append the subquery if it actually contains something
|
||||
if ($subquery !== '') {
|
||||
@ -704,7 +704,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
||||
$componentAlias = key($this->_aliasMap);
|
||||
|
||||
// get short alias
|
||||
$alias = $this->getShortAlias($componentAlias);
|
||||
$alias = $this->getTableAlias($componentAlias);
|
||||
$primaryKey = $alias . '.' . $table->getIdentifier();
|
||||
|
||||
// initialize the base of the subquery
|
||||
@ -970,8 +970,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
||||
$this->needsSubquery = true;
|
||||
}
|
||||
|
||||
$localAlias = $this->getShortAlias($parent, $table->getTableName());
|
||||
$foreignAlias = $this->getShortAlias($componentAlias, $relation->getTable()->getTableName());
|
||||
$localAlias = $this->getTableAlias($parent, $table->getTableName());
|
||||
$foreignAlias = $this->getTableAlias($componentAlias, $relation->getTable()->getTableName());
|
||||
$localSql = $this->_conn->quoteIdentifier($table->getTableName()) . ' ' . $localAlias;
|
||||
$foreignSql = $this->_conn->quoteIdentifier($relation->getTable()->getTableName()) . ' ' . $foreignAlias;
|
||||
|
||||
@ -992,7 +992,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
||||
|
||||
$assocPath = $prevPath . '.' . $asf->getComponentName();
|
||||
|
||||
$assocAlias = $this->getShortAlias($assocPath, $asf->getTableName());
|
||||
$assocAlias = $this->getTableAlias($assocPath, $asf->getTableName());
|
||||
|
||||
$queryPart = $join . $assocTableName . ' ' . $assocAlias . ' ON ' . $localAlias . '.'
|
||||
. $table->getIdentifier() . ' = '
|
||||
@ -1070,7 +1070,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
||||
$tableName = $table->getTableName();
|
||||
|
||||
// get the short alias for this table
|
||||
$tableAlias = $this->getShortAlias($componentAlias, $tableName);
|
||||
$tableAlias = $this->getTableAlias($componentAlias, $tableName);
|
||||
// quote table name
|
||||
$queryPart = $this->_conn->quoteIdentifier($tableName);
|
||||
|
||||
@ -1115,7 +1115,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
||||
$table = $map['table'];
|
||||
|
||||
// build the query base
|
||||
$q = 'SELECT COUNT(DISTINCT ' . $this->getShortAlias($table->getTableName())
|
||||
$q = 'SELECT COUNT(DISTINCT ' . $this->getTableAlias($table->getTableName())
|
||||
. '.' . $table->getIdentifier()
|
||||
. ') FROM ' . $this->buildFromPart();
|
||||
|
||||
|
@ -257,7 +257,7 @@ class Doctrine_RawSql extends Doctrine_Query_Abstract
|
||||
'parent' => $parent,
|
||||
'relation' => $relation);
|
||||
}
|
||||
$this->addAlias($tableAlias, $componentAlias);
|
||||
$this->addTableAlias($tableAlias, $componentAlias);
|
||||
|
||||
$parent = $currPath;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user