Commit 115cadb0 authored by zYne's avatar zYne

complete support for DISTINCT keyword

parent b097669f
......@@ -339,6 +339,15 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
{
$refs = Doctrine_Tokenizer::bracketExplode($dql, ',');
$pos = strpos(trim($refs[0]), ' ');
$first = substr($refs[0], 0, $pos);
if ($first === 'DISTINCT') {
$this->parts['distinct'] = true;
$refs[0] = substr($refs[0], ++$pos);
}
foreach ($refs as $reference) {
$reference = trim($reference);
if (strpos($reference, '(') !== false) {
......@@ -350,6 +359,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
}
} else {
$e = explode('.', $reference);
if (count($e) > 2) {
$this->pendingFields[] = $reference;
......
......@@ -118,8 +118,8 @@ abstract class Doctrine_Query_Abstract extends Doctrine_Hydrate
* @return Doctrine_Query
*/
public function distinct($flag = true)
{
$this->_parts['distinct'] = (bool) $flag;
{
$this->parts['distinct'] = (bool) $flag;
return $this;
}
......@@ -133,7 +133,7 @@ abstract class Doctrine_Query_Abstract extends Doctrine_Hydrate
*/
public function forUpdate($flag = true)
{
$this->_parts[self::FOR_UPDATE] = (bool) $flag;
$this->parts[self::FOR_UPDATE] = (bool) $flag;
return $this;
}
......
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