Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #2080 > unrolled thread

Setting PDO::ATTR_ERRMODE to E_WARNING before connecting!

Started by"A" <a@a.a>
First post2011-06-10 18:41 +0200
Last post2011-06-10 18:41 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.php


Contents

  Setting PDO::ATTR_ERRMODE to E_WARNING before connecting! "A" <a@a.a> - 2011-06-10 18:41 +0200

#2080 — Setting PDO::ATTR_ERRMODE to E_WARNING before connecting!

From"A" <a@a.a>
Date2011-06-10 18:41 +0200
SubjectSetting PDO::ATTR_ERRMODE to E_WARNING before connecting!
Message-ID<isthgr$l9o$1@gregory.bnet.hr>
$dbh = new PDO('mysql:host='.$HOST.';dbname='.$NAME, $USER, $PASS,
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));

The above is supposed to set PDO to E_WARNING instead of PDO exception.
Yet it throws exception.

I know it is possible to do:

$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);

but this works only if connection has been established in the first place. 
What if there is a connection error - then you are forced to handle 
exceptions with try/catch block...

The same applies to PDO::ERRMODE_SILENT

Any solutions to setting error mode before connecting or is this a stupid 
bug?

[toc] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web