The current default error mode for PDO is silent. This means that when an SQL error occurs, no errors or warnings may be emitted and no exceptions thrown unless the developer implements their own explicit error handling.
This causes issues for new developers because the only errors they often see from PDO code are knock-on errors such as “call to fetch() on non-object” - there's no indication that the SQL query (or other action) failed or why.
This RFC proposes that the default PDO error mode by changed to PDO::ERRMODE_EXCEPTION in the next major PHP version.
The silent error mode will still be available for developers to explicitly switch to.
Existing code that does not explicitly set the PDO error mode and relies on the silent mode will be affected by this change. This code can be updated by explicitly setting the PDO error mode to silent.
Next PHP x (PHP 8.0)
No changes to SAPIs.
Existing extensions should not be affected (it is assumed any PDO extensions can already cope with error mode being set to exceptions).
No changes.
This RFC introduces no new constants.
None.
Voting starts 2020-04-13 and ends 2020-04-27
This vote requires a 2/3 majority.
(Pending implementation)
None.