Raise on DB errors; Fixes Business/BinStack#16
Removed `checkDBError` since it isn't used anywhere, and wouldn't be helpful.
This commit is contained in:
parent
26b16ccbe6
commit
7f87c68855
22
required.php
22
required.php
@ -106,7 +106,10 @@ try {
|
||||
'server' => $SETTINGS['database']['server'],
|
||||
'username' => $SETTINGS['database']['user'],
|
||||
'password' => $SETTINGS['database']['password'],
|
||||
'charset' => $SETTINGS['database']['charset']
|
||||
'charset' => $SETTINGS['database']['charset'],
|
||||
'option' => [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
||||
]
|
||||
]);
|
||||
} catch (Exception $ex) {
|
||||
//header('HTTP/1.1 500 Internal Server Error');
|
||||
@ -145,23 +148,6 @@ function dieifnotloggedin() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the previous database action had a problem.
|
||||
* @param array $specials int=>string array with special response messages for SQL errors
|
||||
*/
|
||||
function checkDBError($specials = []) {
|
||||
global $database;
|
||||
$errors = $database->error();
|
||||
if (!is_null($errors[1])) {
|
||||
foreach ($specials as $code => $text) {
|
||||
if ($errors[1] == $code) {
|
||||
sendError($text);
|
||||
}
|
||||
}
|
||||
sendError("A database error occurred:<br /><code>" . $errors[2] . "</code>");
|
||||
}
|
||||
}
|
||||
|
||||
function redirectIfNotLoggedIn() {
|
||||
global $SETTINGS;
|
||||
if ($_SESSION['loggedin'] !== TRUE) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user