mirror of
https://github.com/standardebooks/web.git
synced 2025-07-14 10:31:59 -04:00
Add Db::QueryBool() and some code style updates
This commit is contained in:
parent
854ec6b9df
commit
44901cf3e2
9 changed files with 100 additions and 77 deletions
18
lib/Db.php
18
lib/Db.php
|
@ -54,4 +54,22 @@ class Db{
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single boolean value for the first column database query result.
|
||||
*
|
||||
* This is useful for queries that return a boolean as a result, like `select exists()`.
|
||||
*
|
||||
* @param string $query
|
||||
* @param array<mixed> $args
|
||||
*/
|
||||
public static function QueryBool(string $query, array $args = []): bool{
|
||||
$result = $GLOBALS['DbConnection']->Query($query, $args);
|
||||
|
||||
if(sizeof($result) > 0){
|
||||
return (bool)current((array)$result[0]);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue