Added exists function to database object
This commit is contained in:
parent
ba599d5d1b
commit
6947b726f0
1 changed files with 14 additions and 0 deletions
|
@ -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.
|
||||
*/
|
||||
|
|
Reference in a new issue