¿Por qué no se detecta esta excepción PDO? [cerrado
Tengo un INSERT envuelto en un intento / captura, pero no se detecta una tabla faltante y PHP está produciendo un error en '$ dbh-> prepare'. Configuré 'PDO :: ATTR_ERRMODE' y el valor reflejado en el navegador justo antes de '$ dbh-> prepare' es 2.
Si la tabla existe, el INSERT funciona como esperaba. Solo descubrí que había un problema durante las pruebas cuando dejé caer la tabla a propósito y ejecuté el código.
¿Qué he pasado por alto?
Gracias por adelantad
PHP Error grave: excepción no detectada 'PDOException' con mensaje 'SQLSTATE [HY000]: Error general: 1 no existe esa tabla: submit_info' en C: \ etc \ httpd \ htdocs \ sqlite_data \ collect.php: 309
if($our->db['save']) {
try {
echo $dbh->getAttribute(constant('PDO::ATTR_ERRMODE'));
$sth = $dbh->prepare(
"INSERT INTO submit_info( post_time, post_completed, post_size , script_name, user_agent )" .
" VALUES ( datetime(:request_time, 'unixepoch'), datetime(:current_time, 'unixepoch'), :content_length, :script_filename, :user_agent );"
);
$sth->bindValue(':request_time', (@$_SERVER['REQUEST_TIME'] + 0), PDO::PARAM_INT);
$sth->bindValue(':current_time', time(), PDO::PARAM_INT);
$sth->bindValue(':content_length', (@$_SERVER['CONTENT_LENGTH'] + 0), PDO::PARAM_INT);
$sth->bindValue(':script_filename', @$_SERVER['SCRIPT_FILENAME'], PDO::PARAM_STR);
$sth->bindValue(':user_agent', (@$_SERVER['HTTP_USER_AGENT'] . ''), PDO::PARAM_STR);
$sth->execute();
$our->db['submit_id'] = $dbh->lastInsertId();
} catch (PDOExeption $e) {
echo "There was an error!"; # try writing something to the browser temporarily
errors("Error writing page load information to database: " . $e->getMessage());
$our->db['save'] = FALSE;
}
}