diff --git a/core/database.php b/core/database.php index f06badd8..4f6643a0 100644 --- a/core/database.php +++ b/core/database.php @@ -251,6 +251,20 @@ class Database return $row ? $row[0] : null; } + /** + * Execute an SQL query and returns a bool indicating if any data was returned + */ + public function exists(string $query, array $args = []): bool + { + $_start = microtime(true); + $row = $this->execute($query, $args)->fetch(); + $this->count_time("exists", $_start, $query, $args); + if ($row==null) { + return false; + } + return true; + } + /** * Get the ID of the last inserted row. */