mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-30 01:04:09 +02:00
Prepared filter support for aggregated columns (where VS having)
This commit is contained in:
parent
df07735e9a
commit
1c2142be27
@ -26,8 +26,15 @@ abstract class AbstractQuery extends Query
|
|||||||
protected $contact_id = 'contact_id';
|
protected $contact_id = 'contact_id';
|
||||||
protected $contactgroup_id = 'contactgroup_id';
|
protected $contactgroup_id = 'contactgroup_id';
|
||||||
|
|
||||||
|
protected $aggregateColumnIdx = array();
|
||||||
|
|
||||||
protected $allowCustomVars = false;
|
protected $allowCustomVars = false;
|
||||||
|
|
||||||
|
protected function isAggregateColumn($column)
|
||||||
|
{
|
||||||
|
return array_key_exists($column, $this->aggregateColumnIdx);
|
||||||
|
}
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
parent::init();
|
parent::init();
|
||||||
@ -145,7 +152,17 @@ abstract class AbstractQuery extends Query
|
|||||||
'If you finished here, code has been messed up'
|
'If you finished here, code has been messed up'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->baseQuery->where($this->prepareFilterStringForColumn($col, $value));
|
|
||||||
|
$func = 'filter' . ucfirst($alias);
|
||||||
|
if (method_exists($this, $func)) {
|
||||||
|
$this->$func($value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($this->isAggregateColumn($alias)) {
|
||||||
|
$this->baseQuery->having($this->prepareFilterStringForColumn($col, $value));
|
||||||
|
} else {
|
||||||
|
$this->baseQuery->where($this->prepareFilterStringForColumn($col, $value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user