1
0
mirror of synced 2024-12-13 14:56:01 +03:00

complete support for DISTINCT keyword

This commit is contained in:
zYne 2007-06-08 20:17:17 +00:00
parent b097669fbe
commit 115cadb081
2 changed files with 13 additions and 3 deletions

View File

@ -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;

View File

@ -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;
}