From f44cad9c4ec1a14f3147e97b2d8facfeca43530f Mon Sep 17 00:00:00 2001 From: zYne Date: Tue, 15 May 2007 10:18:34 +0000 Subject: [PATCH] --- draft/new-core/Query.php | 30 ++++++++++++++++-------------- lib/Doctrine/Query/Select.php | 5 ++++- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/draft/new-core/Query.php b/draft/new-core/Query.php index c870d5e1d..bd9994c2e 100644 --- a/draft/new-core/Query.php +++ b/draft/new-core/Query.php @@ -340,12 +340,11 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable { $tableAlias = $this->getTableAlias($componentAlias); - if ( ! isset($this->tables[$tableAlias])) { - throw new Doctrine_Query_Exception('Unknown component path ' . $componentAlias); - } - - $root = current($this->tables); - $table = $this->tables[$tableAlias]; + reset($this->_aliasMap); + $map = current($this->tables); + $root = $map['table']; + $table = $this->_aliasMap[$componentAlias]['table']; + $aggregates = array(); if(isset($this->pendingAggregates[$componentAlias])) { @@ -369,8 +368,8 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable if (is_numeric($arg)) { $arglist[] = $arg; } elseif (count($e) > 1) { - //$tableAlias = $this->getTableAlias($e[0]); - $table = $this->tables[$tableAlias]; + $map = $this->_aliasMap[$e[0]]; + $table = $map['table']; $e[1] = $table->getColumnName($e[1]); @@ -896,7 +895,10 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable $restoreState = false; // load fields if necessary - if ($loadFields && empty($this->pendingFields)) { + if ($loadFields && empty($this->pendingFields) + && empty($this->pendingAggregates) + && empty($this->pendingSubqueries)) { + $this->pendingFields[$componentAlias] = array('*'); $restoreState = true; @@ -906,14 +908,14 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable $this->processPendingFields($componentAlias); } - if ($restoreState) { - $this->pendingFields = array(); - } - - if(isset($this->pendingAggregates[$componentAlias]) || isset($this->pendingAggregates[0])) { $this->processPendingAggregates($componentAlias); } + + if ($restoreState) { + $this->pendingFields = array(); + $this->pendingAggregates = array(); + } } } } diff --git a/lib/Doctrine/Query/Select.php b/lib/Doctrine/Query/Select.php index 3f0a15108..93a76fd83 100644 --- a/lib/Doctrine/Query/Select.php +++ b/lib/Doctrine/Query/Select.php @@ -34,8 +34,11 @@ class Doctrine_Query_Select extends Doctrine_Query_Part { public function parse($dql) { + if ($dql === '' || $dql === null) { + throw new Doctrine_Query_Exception('Empty select part given.'); + } $this->query->parseSelect($dql); - return $this->query; + return $this->query; } }