Added exists function to database object

This commit is contained in:
Matthew Barbour 2020-03-02 15:21:49 +00:00 committed by Shish
parent ba599d5d1b
commit 6947b726f0

View file

@ -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.
*/