diff --git a/lib/Doctrine/Hydrate.php b/lib/Doctrine/Hydrate.php index a7590d2df..d182ec8b0 100644 --- a/lib/Doctrine/Hydrate.php +++ b/lib/Doctrine/Hydrate.php @@ -66,7 +66,7 @@ class Doctrine_Hydrate /** * @var Doctrine_Connection $conn Doctrine_Connection object */ - protected $conn; + protected $_conn; /** * @var Doctrine_View $_view Doctrine_View object, when set this object will use the * the query given by the view object for object population @@ -94,11 +94,6 @@ class Doctrine_Hydrate * and values as sql aliases */ protected $aggregateMap = array(); - /** - * @var Doctrine_Hydrate_Alias $aliasHandler handles the creation and storage of table aliases and - * binds the aliases to component aliases / paths - */ - protected $aliasHandler; /** * @var array $parts SQL query string parts */ @@ -136,7 +131,7 @@ class Doctrine_Hydrate if ( ! ($connection instanceof Doctrine_Connection)) { $connection = Doctrine_Manager::getInstance()->getCurrentConnection(); } - $this->conn = $connection; + $this->_conn = $connection; } public function generateNewAlias($alias) { @@ -262,10 +257,16 @@ class Doctrine_Hydrate } /** * copyAliases + * copy aliases from another Hydrate object * - * @return void + * this method is needed by DQL subqueries which need the aliases + * of the parent query + * + * @param Doctrine_Hydrate $query the query object from which the + * aliases are copied from + * @return Doctrine_Hydrate this object */ - public function copyAliases($query) + public function copyAliases(Doctrine_Hydrate $query) { $this->shortAliases = $query->shortAliases; @@ -273,6 +274,7 @@ class Doctrine_Hydrate } /** * createSubquery + * creates a subquery * * @return Doctrine_Hydrate */ @@ -353,7 +355,7 @@ class Doctrine_Hydrate */ public function getConnection() { - return $this->conn; + return $this->_conn; } /** * setView @@ -443,7 +445,7 @@ class Doctrine_Hydrate */ public function execute($params = array(), $return = Doctrine::FETCH_RECORD) { - $params = $this->conn->convertBooleans(array_merge($this->params, $params)); + $params = $this->_conn->convertBooleans(array_merge($this->params, $params)); $params = $this->convertEnums($params); if ( ! $this->_view) { @@ -453,16 +455,16 @@ class Doctrine_Hydrate } if ($this->isLimitSubqueryUsed() && - $this->conn->getDBH()->getAttribute(Doctrine::ATTR_DRIVER_NAME) !== 'mysql') { + $this->_conn->getDBH()->getAttribute(Doctrine::ATTR_DRIVER_NAME) !== 'mysql') { $params = array_merge($params, $params); } if ($this->type !== self::SELECT) { - return $this->conn->exec($query, $params); + return $this->_conn->exec($query, $params); } - $stmt = $this->conn->execute($query, $params); + $stmt = $this->_conn->execute($query, $params); $array = (array) $this->parseData($stmt); if (empty($this->_aliasMap)) { throw new Doctrine_Hydrate_Exception("Couldn't execute query. Component alias map was empty."); diff --git a/lib/Doctrine/Query.php b/lib/Doctrine/Query.php index bee0eca63..137c3e239 100644 --- a/lib/Doctrine/Query.php +++ b/lib/Doctrine/Query.php @@ -379,7 +379,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable $argStr = substr($func, ($pos + 1), -1); $args = explode(',', $argStr); - $func = call_user_func_array(array($this->conn->expression, $name), $args); + $func = call_user_func_array(array($this->_conn->expression, $name), $args); if(substr($func, 0, 1) !== '(') { $pos = strpos($func, '('); @@ -641,10 +641,10 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable $subquery = $this->getLimitSubquery(); - switch (strtolower($this->conn->getName())) { + switch (strtolower($this->_conn->getName())) { case 'mysql': // mysql doesn't support LIMIT in subqueries - $list = $this->conn->execute($subquery, $params)->fetchAll(PDO::FETCH_COLUMN); + $list = $this->_conn->execute($subquery, $params)->fetchAll(PDO::FETCH_COLUMN); $subquery = implode(', ', $list); break; case 'pgsql': @@ -670,7 +670,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable $q .= ( ! empty($this->parts['orderby']))? ' ORDER BY ' . implode(', ', $this->parts['orderby']) : ''; if ($modifyLimit) { - $q = $this->conn->modifyLimitQuery($q, $this->parts['limit'], $this->parts['offset']); + $q = $this->_conn->modifyLimitQuery($q, $this->parts['limit'], $this->parts['offset']); } // return to the previous state @@ -710,7 +710,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable // initialize the base of the subquery $subquery = 'SELECT DISTINCT ' . $primaryKey; - if ($this->conn->getDBH()->getAttribute(PDO::ATTR_DRIVER_NAME) == 'pgsql') { + if ($this->_conn->getDBH()->getAttribute(PDO::ATTR_DRIVER_NAME) == 'pgsql') { // pgsql needs the order by fields to be preserved in select clause foreach ($this->parts['orderby'] as $part) { @@ -746,7 +746,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable $subquery .= ( ! empty($this->parts['orderby']))? ' ORDER BY ' . implode(', ', $this->parts['orderby']) : ''; // add driver specific limit clause - $subquery = $this->conn->modifyLimitQuery($subquery, $this->parts['limit'], $this->parts['offset']); + $subquery = $this->_conn->modifyLimitQuery($subquery, $this->parts['limit'], $this->parts['offset']); $parts = Doctrine_Tokenizer::quoteExplode($subquery, ' ', "'", "'"); @@ -972,8 +972,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable $localAlias = $this->getShortAlias($parent, $table->getTableName()); $foreignAlias = $this->getShortAlias($componentAlias, $relation->getTable()->getTableName()); - $localSql = $this->conn->quoteIdentifier($table->getTableName()) . ' ' . $localAlias; - $foreignSql = $this->conn->quoteIdentifier($relation->getTable()->getTableName()) . ' ' . $foreignAlias; + $localSql = $this->_conn->quoteIdentifier($table->getTableName()) . ' ' . $localAlias; + $foreignSql = $this->_conn->quoteIdentifier($relation->getTable()->getTableName()) . ' ' . $foreignAlias; $map = $relation->getTable()->inheritanceMap; @@ -1063,16 +1063,16 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable public function loadRoot($name, $componentAlias) { // get the connection for the component - $this->conn = Doctrine_Manager::getInstance() + $this->_conn = Doctrine_Manager::getInstance() ->getConnectionForComponent($name); - $table = $this->conn->getTable($name); + $table = $this->_conn->getTable($name); $tableName = $table->getTableName(); // get the short alias for this table $tableAlias = $this->getShortAlias($componentAlias, $tableName); // quote table name - $queryPart = $this->conn->quoteIdentifier($tableName); + $queryPart = $this->_conn->quoteIdentifier($tableName); if ($this->type === self::SELECT) { $queryPart .= ' ' . $tableAlias;