Take the State of PHP 2026 Survey →

Change default PDO error mode View as Markdown

Implemented (PHP 8.0)
Authors
AllenJB, php.lists@allenjb.me.uk
Date
2020-03-28
Version
1.0
Source
wiki.php.net/rfc/pdo_default_errmode

Vote

Change the default PDO error handling mode to PDO::ERRMODE_EXCEPTION? closed
Yes
49
No
2
51 voters
ajf Yes 2020-04-14 16:23
alcaeus Yes 2020-04-20 11:16
asgrim Yes 2020-04-13 15:04
ashnazg Yes 2020-04-15 13:19
beberlei Yes 2020-04-13 13:25
brzuchal Yes 2020-04-14 04:29
bwoebi Yes 2020-04-14 10:53
carusogabriel Yes 2020-04-14 22:38
colinodell Yes 2020-04-14 11:11
cschneid No 2020-04-13 16:04
danack Yes 2020-04-13 12:45
daverandom Yes 2020-04-17 18:17
derick Yes 2020-04-14 10:46
duncan3dc Yes 2020-04-13 12:52
duodraco Yes 2020-04-15 16:58
ekin Yes 2020-04-13 14:08
galvao Yes 2020-04-13 13:35
geekcom Yes 2020-04-13 14:14
girgias Yes 2020-04-13 13:33
jasny Yes 2020-04-22 23:55
jbnahan Yes 2020-04-21 06:13
jhdxr Yes 2020-04-15 16:55
kalle Yes 2020-04-13 13:44
kelunik Yes 2020-04-19 20:20
kguest Yes 2020-04-21 08:03
klaussilveira Yes 2020-04-21 12:53
kocsismate Yes 2020-04-13 13:00
krakjoe Yes 2020-04-15 06:55
lcobucci Yes 2020-04-23 13:29
marandall Yes 2020-04-13 15:04
marcio Yes 2020-04-23 17:05
mariano Yes 2020-04-13 20:35
mbeccati Yes 2020-04-14 08:49
nicolasgrekas Yes 2020-04-13 18:18
nikic Yes 2020-04-13 16:08
ocramius Yes 2020-04-13 12:45
peehaa Yes 2020-04-13 13:40
petk Yes 2020-04-14 04:40
pmjones Yes 2020-04-13 12:49
pmmaga Yes 2020-04-17 13:01
pollita Yes 2020-04-20 12:57
ramsey Yes 2020-04-13 17:36
reywob Yes 2020-04-14 14:29
royopa Yes 2020-04-13 14:06
ruudboon Yes 2020-04-20 05:43
salathe Yes 2020-04-14 10:20
sergey Yes 2020-04-20 11:19
svpernova09 Yes 2020-04-14 12:59
trowski Yes 2020-04-21 19:24
yunosh No 2020-04-13 17:39
zimt Yes 2020-04-16 23:14

Discussions on the mailing list

Changing the default PDO error mode
by AllenJB · 7 messages
[RFC] Change default PDO error mode
by AllenJB · 5 messages
[RFC][VOTE] Change default PDO error mode
by AllenJB · 8 messages

RFC text

Copied from wiki.php.net, last synchronized Oct 13, 2026 11:51 UTC

Introduction

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.

Proposal

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.

Backward Incompatible Changes

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.

Proposed PHP Version(s)

Next PHP x (PHP 8.0)

RFC Impact

To SAPIs

No changes to SAPIs.

To Existing Extensions

Existing extensions should not be affected (it is assumed any PDO extensions can already cope with error mode being set to exceptions).

To Opcache

No changes.

New Constants

This RFC introduces no new constants.

Open Issues

None.

Proposed Voting Choices

Voting starts 2020-04-13 and ends 2020-04-27

This vote requires a 2/3 majority.

Vote: Change the default PDO error handling mode to PDO::ERRMODE_EXCEPTION? — Yes: 49 · No: 2 (closed)

Patches and Tests

PR: https://github.com/php/php-src/pull/5388

Implementation

(Pending implementation)

References

Rejected Features

None.