complete support for DISTINCT keyword
This commit is contained in:
parent
b097669fbe
commit
115cadb081
@ -339,6 +339,15 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
|||||||
{
|
{
|
||||||
$refs = Doctrine_Tokenizer::bracketExplode($dql, ',');
|
$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) {
|
foreach ($refs as $reference) {
|
||||||
$reference = trim($reference);
|
$reference = trim($reference);
|
||||||
if (strpos($reference, '(') !== false) {
|
if (strpos($reference, '(') !== false) {
|
||||||
@ -350,6 +359,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
$e = explode('.', $reference);
|
$e = explode('.', $reference);
|
||||||
if (count($e) > 2) {
|
if (count($e) > 2) {
|
||||||
$this->pendingFields[] = $reference;
|
$this->pendingFields[] = $reference;
|
||||||
|
@ -119,7 +119,7 @@ abstract class Doctrine_Query_Abstract extends Doctrine_Hydrate
|
|||||||
*/
|
*/
|
||||||
public function distinct($flag = true)
|
public function distinct($flag = true)
|
||||||
{
|
{
|
||||||
$this->_parts['distinct'] = (bool) $flag;
|
$this->parts['distinct'] = (bool) $flag;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ abstract class Doctrine_Query_Abstract extends Doctrine_Hydrate
|
|||||||
*/
|
*/
|
||||||
public function forUpdate($flag = true)
|
public function forUpdate($flag = true)
|
||||||
{
|
{
|
||||||
$this->_parts[self::FOR_UPDATE] = (bool) $flag;
|
$this->parts[self::FOR_UPDATE] = (bool) $flag;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user