From 201c6b8194059b3fbab5be5bee6149e641f0102f Mon Sep 17 00:00:00 2001 From: zYne Date: Tue, 14 Aug 2007 20:16:31 +0000 Subject: [PATCH] fixes #419 --- lib/Doctrine/Query/Groupby.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/Doctrine/Query/Groupby.php b/lib/Doctrine/Query/Groupby.php index 59117d4b1..88c6d8ee7 100644 --- a/lib/Doctrine/Query/Groupby.php +++ b/lib/Doctrine/Query/Groupby.php @@ -35,7 +35,7 @@ class Doctrine_Query_Groupby extends Doctrine_Query_Part /** * DQL GROUP BY PARSER * parses the group by part of the query string - + * * @param string $str * @return void */ @@ -45,11 +45,17 @@ class Doctrine_Query_Groupby extends Doctrine_Query_Part foreach (explode(',', $str) as $reference) { $reference = trim($reference); $e = explode('.', $reference); - $field = array_pop($e); - $ref = implode('.', $e); - $this->query->load($ref); - - $r[] = $this->query->getTableAlias($ref) . '.' . $field; + + if (count($e) > 1) { + $field = array_pop($e); + $ref = implode('.', $e); + $this->query->load($ref); + + $r[] = $this->query->getTableAlias($ref) . '.' . $field; + } else { + $alias = end($e); + $r[] = $this->query->getAggregateAlias($alias); + } } return implode(', ', $r); }