Skip to content

Instantly share code, notes, and snippets.

View itsChris's full-sized avatar
🎯
Focusing

Christian M. Casutt itsChris

🎯
Focusing
View GitHub Profile
@CMCDragonkai
CMCDragonkai / PDO Error Handling.md
Last active March 31, 2021 07:50
PDO Error Handling #php #mysql

PDO Error Handling

The first step is to switch on exceptions. When bootstrapping PDO, make sure to do:

$opts = [
  PDO::ATTR_ERRMODE                  => PDO::ERRMODE_EXCEPTION,
  PDO::ATTR_DEFAULT_FETCH_MODE       => PDO::FETCH_BOTH,
 PDO::ATTR_EMULATE_PREPARES => false,