FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Setting PDO::ATTR_ERRMODE to E_WARNING before connecting!
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Setting PDO::ATTR_ERRMODE to E_WARNING before connecting! [message #174414] Fri, 10 June 2011 16:41
A is currently offline  A
Messages: 17
Registered: June 2011
Karma: 0
Junior Member
$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?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: object in $_SESSION
Next Topic: Joining two arrays?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 19:27:18 GMT 2024

Total time taken to generate the page: 0.07588 seconds