PHP RFC: Change Default PDO Error Mode


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.

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


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


Proposed Voting Choices

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

This vote requires a 2/3 majority.

Change the default PDO error handling mode to PDO::ERRMODE_EXCEPTION?
Real name Yes No
ajf (ajf)  
alcaeus (alcaeus)  
asgrim (asgrim)  
ashnazg (ashnazg)  
beberlei (beberlei)  
brzuchal (brzuchal)  
bwoebi (bwoebi)  
carusogabriel (carusogabriel)  
colinodell (colinodell)  
cschneid (cschneid)  
danack (danack)  
daverandom (daverandom)  
derick (derick)  
duncan3dc (duncan3dc)  
duodraco (duodraco)  
ekin (ekin)  
galvao (galvao)  
geekcom (geekcom)  
girgias (girgias)  
jasny (jasny)  
jbnahan (jbnahan)  
jhdxr (jhdxr)  
kalle (kalle)  
kelunik (kelunik)  
kguest (kguest)  
klaussilveira (klaussilveira)  
kocsismate (kocsismate)  
krakjoe (krakjoe)  
lcobucci (lcobucci)  
marandall (marandall)  
marcio (marcio)  
mariano (mariano)  
mbeccati (mbeccati)  
nicolasgrekas (nicolasgrekas)  
nikic (nikic)  
ocramius (ocramius)  
peehaa (peehaa)  
petk (petk)  
pmjones (pmjones)  
pmmaga (pmmaga)  
pollita (pollita)  
ramsey (ramsey)  
reywob (reywob)  
royopa (royopa)  
ruudboon (ruudboon)  
salathe (salathe)  
sergey (sergey)  
svpernova09 (svpernova09)  
trowski (trowski)  
yunosh (yunosh)  
zimt (zimt)  
Final result: 49 2
This poll has been closed.

Patches and Tests


(Pending implementation)


Rejected Features


rfc/pdo_default_errmode.txt · Last modified: 2020/05/05 14:13 by nikic