Checking returnvalue of PDO::execute for errors in database->save()

This commit is contained in:
Maarten Hoogveld 2020-05-27 02:36:31 +02:00
parent b2295da641
commit ff6d1c7261
1 changed files with 14 additions and 1 deletions

View File

@ -1227,7 +1227,15 @@ include "root.php";
if ($prep_statement) {
//get the data
try {
$prep_statement->execute();
$res_exec = $prep_statement->execute();
if ($res_exec === false) {
$errInfo = $prep_statement->errorInfo();
if (isset($errInfo[2])) {
throw new RuntimeException($errInfo[2]);
} else {
throw new RuntimeException("Error executing SQL statement");
}
}
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
}
catch(PDOException $e) {
@ -1235,6 +1243,11 @@ include "root.php";
echo $sql;
exit;
}
catch(RuntimeException $e) {
echo 'Caught exception: ', $e->getMessage(), "<br/><br/>\n";
echo $sql;
exit;
}
//set the action
if (count($result) > 0) {