mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-04-08 17:15:08 +02:00
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…
x
Reference in New Issue
Block a user