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 *