Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision |
pdo:exception_handling [2016/10/14 08:33] – created peter | pdo:exception_handling [2020/07/15 09:30] (current) – external edit 127.0.0.1 |
---|
PDO has three error handling modes. | PDO has three error handling modes. |
| |
* PDO::ERRMODE_SILENT acts like mysql_* where you must check each result and then look at $db->errorInfo(); to get the error details. | * **PDO::ERRMODE_SILENT** acts like mysql_* where you must check each result and then look at $db->errorInfo(); to get the error details. |
* PDO::ERRMODE_WARNING throws PHP Warnings | * **PDO::ERRMODE_WARNING** throws PHP Warnings |
* PDO::ERRMODE_EXCEPTION throws PDOException. In my opinion this is the mode you should use. It acts very much like or die(mysql_error()); when it isn't caught, but unlike or die() the PDOException can be caught and handled gracefully if you choose to do so. | * **PDO::ERRMODE_EXCEPTION** throws PDOException. In my opinion this is the mode you should use. It acts very much like or die(mysql_error()); when it isn't caught, but unlike or die() the PDOException can be caught and handled gracefully if you choose to do so. |
| |
<code php> | <code php> |
</code> | </code> |
| |
// ...then much later... | ...then much later... |
| |
<code php> | <code php> |