Implement GROUP BY clause functionality

This commit is contained in:
Alexander Fuhr 2014-10-06 11:34:04 +02:00
parent e96065e065
commit 97d2a920db
1 changed files with 24 additions and 0 deletions

View File

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