From 66ee5fb3251099dfcb590b6c73db5bd5ac655bbf Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 24 Jan 2017 10:58:53 +0100 Subject: [PATCH] IcingaZoneTable: use subquery count() fixes #742 --- application/tables/IcingaZoneTable.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/application/tables/IcingaZoneTable.php b/application/tables/IcingaZoneTable.php index c9f1dd7d..0a44b122 100644 --- a/application/tables/IcingaZoneTable.php +++ b/application/tables/IcingaZoneTable.php @@ -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(