Checking returnvalue of PDO::execute for errors in database->save()
This commit is contained in:
parent
b2295da641
commit
ff6d1c7261
|
|
@ -1227,7 +1227,15 @@ include "root.php";
|
||||||
if ($prep_statement) {
|
if ($prep_statement) {
|
||||||
//get the data
|
//get the data
|
||||||
try {
|
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);
|
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||||
}
|
}
|
||||||
catch(PDOException $e) {
|
catch(PDOException $e) {
|
||||||
|
|
@ -1235,6 +1243,11 @@ include "root.php";
|
||||||
echo $sql;
|
echo $sql;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
catch(RuntimeException $e) {
|
||||||
|
echo 'Caught exception: ', $e->getMessage(), "<br/><br/>\n";
|
||||||
|
echo $sql;
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
//set the action
|
//set the action
|
||||||
if (count($result) > 0) {
|
if (count($result) > 0) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue