From 9a0e47a3e1ed081461db1252d7c00a27933883e2 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 3 Aug 2015 14:49:33 +0200 Subject: [PATCH] SimpleQuery: Add method hasResult() refs #9632 --- library/Icinga/Data/SimpleQuery.php | 10 ++++++++++ library/Icinga/Repository/RepositoryQuery.php | 10 ++++++++++ .../library/Monitoring/DataView/DataView.php | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/library/Icinga/Data/SimpleQuery.php b/library/Icinga/Data/SimpleQuery.php index 33745a822..2dcecfc9c 100644 --- a/library/Icinga/Data/SimpleQuery.php +++ b/library/Icinga/Data/SimpleQuery.php @@ -422,6 +422,16 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator return $this->hasMore; } + /** + * Return whether this query will or has yielded any result + * + * @return bool + */ + public function hasResult() + { + return $this->iteratorPosition !== null || $this->fetchRow() !== false; + } + /** * Set a limit count and offset to the query * diff --git a/library/Icinga/Repository/RepositoryQuery.php b/library/Icinga/Repository/RepositoryQuery.php index 163bb40ff..c975654db 100644 --- a/library/Icinga/Repository/RepositoryQuery.php +++ b/library/Icinga/Repository/RepositoryQuery.php @@ -367,6 +367,16 @@ class RepositoryQuery implements QueryInterface, SortRules, Iterator return $this->query->hasMore(); } + /** + * Return whether this query will or has yielded any result + * + * @return bool + */ + public function hasResult() + { + return $this->query->hasResult(); + } + /** * Limit this query's results * diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index 49f14a2e9..11543351c 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -433,6 +433,16 @@ abstract class DataView implements QueryInterface, SortRules, IteratorAggregate return $this->query->hasMore(); } + /** + * Return whether this query will or has yielded any result + * + * @return bool + */ + public function hasResult() + { + return $this->query->hasResult(); + } + /** * Set a limit count and offset *