mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +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;
|
protected $count;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GROUP BY clauses
|
||||||
|
*
|
||||||
|
* @var string|array
|
||||||
|
*/
|
||||||
|
protected $group;
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
$this->db = $this->ds->getDbAdapter();
|
$this->db = $this->ds->getDbAdapter();
|
||||||
@ -100,6 +107,10 @@ class DbQuery extends SimpleQuery
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->group) {
|
||||||
|
$select->group($this->group);
|
||||||
|
}
|
||||||
|
|
||||||
$select->columns($this->columns);
|
$select->columns($this->columns);
|
||||||
$this->applyFilterSql($select);
|
$this->applyFilterSql($select);
|
||||||
|
|
||||||
@ -300,4 +311,17 @@ class DbQuery extends SimpleQuery
|
|||||||
{
|
{
|
||||||
return (string) $this->getSelectQuery();
|
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