Commit 1b0d2c78 authored by zYne's avatar zYne

new method isDistinct

parent 41ee9173
...@@ -43,6 +43,8 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable { ...@@ -43,6 +43,8 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
private $tableStack; private $tableStack;
private $relationStack = array(); private $relationStack = array();
private $distinct;
/** /**
* create * create
* returns a new Doctrine_Query object * returns a new Doctrine_Query object
...@@ -60,6 +62,13 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable { ...@@ -60,6 +62,13 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
public function getRelationStack() { public function getRelationStack() {
return $this->relationStack; return $this->relationStack;
} }
public function isDistinct($distinct = null) {
if(isset($distinct))
$this->isDistinct = (bool) $distinct;
return $this->isDistinct;
}
/** /**
* count * count
* *
...@@ -293,7 +302,12 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable { ...@@ -293,7 +302,12 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
} }
// build the basic query // build the basic query
$q = "SELECT ".implode(", ",$this->parts["select"]).
$str = '';
if($this->isDistinct())
$str = 'DISTINCT ';
$q = "SELECT ".$str.implode(", ",$this->parts["select"]).
" FROM "; " FROM ";
foreach($this->parts["from"] as $tname => $bool) { foreach($this->parts["from"] as $tname => $bool) {
......
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