2024-12-13 15:38:18 +00:00
|
|
|
<?
|
|
|
|
|
|
|
|
function get_value_from_session(string $key, mixed $default = null) : mixed
|
|
|
|
{
|
|
|
|
return isset($_SESSION[$key]) ? $_SESSION[$key] : $default;
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_value_from_array(array $ar, string $key, mixed $default = null) : mixed
|
|
|
|
{
|
|
|
|
return isset($ar[$key]) ? $ar[$key] : $default;
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_value(mixed $var) : mixed
|
|
|
|
{
|
|
|
|
return isset($var) ? $var : null;
|
|
|
|
}
|
|
|
|
|
2024-12-17 06:34:35 +00:00
|
|
|
function get_value_or_default(mixed $var, mixed $default = null) : mixed {
|
|
|
|
return isset($var) ? $var : $default;
|
|
|
|
}
|
|
|
|
|
|
|
|
function show_pdo_errors_if_any($pdo) {// Check for errors after the query execution
|
|
|
|
$errorInfo = $pdo->errorInfo();
|
|
|
|
if ($errorInfo[0] != '00000') {
|
|
|
|
// If there's an error (the SQLSTATE isn't '00000', which means no error)
|
|
|
|
echo "Error: " . $errorInfo[2]; // The third element contains the error message
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-12-13 15:38:18 +00:00
|
|
|
?>
|