From 3ffd63343e43bbd3f9e844bfcbe227ab33243f54 Mon Sep 17 00:00:00 2001 From: zYne Date: Fri, 11 May 2007 22:12:34 +0000 Subject: [PATCH] --- draft/new-core/Query.php | 73 +++++++--------------------------------- 1 file changed, 13 insertions(+), 60 deletions(-) diff --git a/draft/new-core/Query.php b/draft/new-core/Query.php index 31ea4ca38..880bdc088 100644 --- a/draft/new-core/Query.php +++ b/draft/new-core/Query.php @@ -43,6 +43,9 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable { * @param boolean $limitSubqueryUsed */ private $limitSubqueryUsed = false; + + + protected $_status = array('needsSubquery' => true); /** * @param boolean $isSubquery whether or not this query object is a subquery of another * query object @@ -1062,7 +1065,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable { $relation = $table->getRelation($name); $this->_aliasMap[$componentAlias] = array('parent' => $parent, 'relation' => $relation); - if( ! $fk->isOneToOne()) { + if( ! $relation->isOneToOne()) { $this->needsSubquery = true; } @@ -1114,8 +1117,15 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable { . $fk->getLocal() . ' = ' . $tname2 . '.' . $fk->getForeign() . $joinCondition; } - - + } + if ($loadFields) { + if(isset($this->pendingFields[$componentAlias])) { + $this->processPendingFields($componentAlias); + } + if(isset($this->pendingAggregates[$componentAlias]) || + (current($this->tables) === $table && isset($this->pendingAggregates[0]))) { + $this->processPendingAggregates($componentAlias); + } } } } @@ -1180,29 +1190,6 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable { $currPath .= '.' . $name; if($key == 0) { - $currPath = substr($currPath,1); - - $this->conn = Doctrine_Manager::getInstance() - ->getConnectionForComponent($name); - - $table = $this->conn->getTable($name); - - - $tname = $this->aliasHandler->getShortAlias($table->getTableName()); - - if( ! isset($this->tableAliases[$currPath])) { - $this->tableIndexes[$tname] = 1; - } - - $this->parts['from'] = $this->conn->quoteIdentifier($table->getTableName()); - - if ($this->type === self::SELECT) { - $this->parts['from'] .= ' ' . $tname; - } - - $this->tableAliases[$currPath] = $tname; - - $tableName = $tname; } else { $index += strlen($e[($key - 1)]) + 1; @@ -1261,40 +1248,6 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable { $this->tableStack[] = $table; - if( ! isset($this->tables[$tableName])) { - $this->tables[$tableName] = $table; - - if ($loadFields) { - - $skip = false; - - if ( ! empty($this->pendingFields) || - ! empty($this->pendingAggregates)) { - $skip = true; - } - - if ($componentAlias) { - $this->compAliases[$componentAlias] = $currPath; - - if(isset($this->pendingFields[$componentAlias])) { - $this->processPendingFields($componentAlias); - $skip = true; - } - if(isset($this->pendingAggregates[$componentAlias]) || - (current($this->tables) === $table && isset($this->pendingAggregates[0])) - ) { - $this->processPendingAggregates($componentAlias); - $skip = true; - } - } - - if ( ! $skip) { - $this->parseFields($fullname, $tableName, $e2, $currPath); - } - } - } - - $prevPath = $currPath; $prevTable = $tableName; } catch(Exception $e) {