Implement GROUP BY clause functionality
This commit is contained in:
parent
e96065e065
commit
97d2a920db
|
@ -59,6 +59,13 @@ class DbQuery extends SimpleQuery
|
|||
*/
|
||||
protected $count;
|
||||
|
||||
/**
|
||||
* GROUP BY clauses
|
||||
*
|
||||
* @var string|array
|
||||
*/
|
||||
protected $group;
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->db = $this->ds->getDbAdapter();
|
||||
|
@ -100,6 +107,10 @@ class DbQuery extends SimpleQuery
|
|||
}
|
||||
}
|
||||
|
||||
if ($this->group) {
|
||||
$select->group($this->group);
|
||||
}
|
||||
|
||||
$select->columns($this->columns);
|
||||
$this->applyFilterSql($select);
|
||||
|
||||
|
@ -300,4 +311,17 @@ class DbQuery extends SimpleQuery
|
|||
{
|
||||
return (string) $this->getSelectQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a GROUP BY clause
|
||||
*
|
||||
* @param string|array $group
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function group($group)
|
||||
{
|
||||
$this->group = $group;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue