IcingaZoneTable: use subquery count()

fixes #742
This commit is contained in:
Thomas Gelf 2017-01-24 10:58:53 +01:00
parent d4b769b8d7
commit 66ee5fb325

View File

@ -40,6 +40,20 @@ class IcingaZoneTable extends IcingaObjectTable
);
}
public function count()
{
$db = $this->db();
$sub = clone($this->getBaseQuery());
$sub->columns($this->getColumns());
$this->applyFiltersToQuery($sub);
$query = $db->select()->from(
array('sub' => $sub),
'COUNT(*)'
);
return $db->fetchOne($query);
}
public function getBaseQuery()
{
return $this->db()->select()->from(