diff --git a/reference/pdo/error-handling.xml b/reference/pdo/error-handling.xml index af26c27ec8..ca4c03c7dd 100644 --- a/reference/pdo/error-handling.xml +++ b/reference/pdo/error-handling.xml @@ -95,6 +95,47 @@ try { + + + PDO::__construct will always throw a PDOException if the connection fails + regardless of which PDO::ATTR_ERRMODE is currently set. Uncaught Exceptions are fatal. + + + + + Create a PDO instance and set the error mode from the constructor + + PDO::ERRMODE_WARNING)); +} catch (PDOException $e) { + echo 'Connection failed: ' . $e->getMessage(); + exit; +} + +// This will cause PDO to throw an error of level E_WARNING instead of an exception (when the table doesn't exist) +$dbh->query("SELECT wrongcolumn FROM wrongtable"); +?> +]]> + + &example.outputs; + + + + +