Add Db::QueryBool() and some code style updates

This commit is contained in:
Alex Cabal 2024-09-15 13:50:13 -05:00
parent 854ec6b9df
commit 44901cf3e2
9 changed files with 100 additions and 77 deletions

View file

@ -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;
}
}