Commit 81d39c50 authored by zYne's avatar zYne

--no commit message

--no commit message
parent d70e1041
...@@ -1249,15 +1249,23 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable ...@@ -1249,15 +1249,23 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
// initialize temporary variables // initialize temporary variables
$where = $this->parts['where']; $where = $this->parts['where'];
$having = $this->parts['having']; $having = $this->parts['having'];
$groupby = $this->parts['groupby'];
$map = reset($this->_aliasMap); $map = reset($this->_aliasMap);
$componentAlias = key($this->_aliasMap); $componentAlias = key($this->_aliasMap);
$table = $map['table']; $table = $map['table'];
// build the query base // build the query base
$q = 'SELECT COUNT(DISTINCT ' . $this->getTableAlias($componentAlias) $q = 'SELECT COUNT(DISTINCT ' . $this->getTableAlias($componentAlias)
. '.' . $table->getIdentifier() . '.' . $table->getIdentifier()
. ') FROM ' . $this->buildFromPart(); . ')';
foreach ($this->parts['select'] as $field) {
if (strpos($field, '(') !== false) {
$q .= ', ' . $field;
}
}
$q .= ' FROM ' . $this->buildFromPart();
// append column aggregation inheritance (if needed) // append column aggregation inheritance (if needed)
$string = $this->applyInheritance(); $string = $this->applyInheritance();
...@@ -1267,6 +1275,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable ...@@ -1267,6 +1275,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
} }
// append conditions // append conditions
$q .= ( ! empty($where)) ? ' WHERE ' . implode(' AND ', $where) : ''; $q .= ( ! empty($where)) ? ' WHERE ' . implode(' AND ', $where) : '';
$q .= ( ! empty($groupby)) ? ' GROUP BY ' . implode(', ', $groupby) : '';
$q .= ( ! empty($having)) ? ' HAVING ' . implode(' AND ', $having): ''; $q .= ( ! empty($having)) ? ' HAVING ' . implode(' AND ', $having): '';
if ( ! is_array($params)) { if ( ! is_array($params)) {
......
...@@ -123,8 +123,8 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase ...@@ -123,8 +123,8 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase
try { try {
$q->count(); $q->count();
$this->pass();
} catch (Doctrine_Exception $e) { } catch (Doctrine_Exception $e) {
$this->fail(); $this->fail();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment