Re: [PHP-DB] PDO Exception Handling Question

2007-04-20 Thread Jerry Schwartz
I hope by now you figured this out, but you have to use $dbh-setAttribute() to enable exception handling for anything but the initial object creation. Worse yet, as of 2007/04/20 the return values of setAttribute are reversed. It returns TRUE on failure and FALSE on success. Rodney Topor

Re: [PHP-DB] PDO Exception Handling Question

2006-05-03 Thread Cyril PIERRE de GEYER
But if there is an error in the SELECT query (either syntax error, or reference to missing table), then no exception is raised, and control just continues in the try block with a null result from the query. Is this the intended behaviour? Hey, it's really fun I was looking here and on

Re: [PHP-DB] PDO Exception Handling Question

2006-05-03 Thread Cyril PIERRE de GEYER
And also my question is : Why did the PDO creators (Wez the King?) decide to choose the silent mode for being the default one ? Why not defining the ERRMODE_WARNING by default ? Or perhaps I misunderstand something, and I would be very happy to learn a bit :) Thx Cyril -- PHP Database

Re: [PHP-DB] PDO Exception Handling Question

2006-05-03 Thread Cyril PIERRE de GEYER
Read on otn : PDO_ERRMODE_SILENT This is the default mode; it will simply set the error code for you to inspect using the errorCode() and errorInfo() methods of both the statement and database handle objects. if (!$dbh-exec($sql)) { echo $dbh-errorCode() . br; $info =

Re: [PHP-DB] PDO Exception Handling Question

2006-04-02 Thread chris smith
On 4/2/06, Rodney Topor [EMAIL PROTECTED] wrote: I've just started using PDO with PHP 5.1 and MySQL 5.0. Everything seems to work fine, except for one issue with the following example from the PHP manual. ?php try { $dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass);

Re: [PHP-DB] PDO Exception Handling Question

2006-04-02 Thread Rodney Topor
I did some more checking. If there is an error in the new PDO(...) constructor call, then it does get into the catch block and print an appropriate error message. (Good. Perhaps I was previously mistaken.) But if there is an error in the SELECT query (either syntax error, or reference to

[PHP-DB] PDO Exception Handling Question

2006-04-01 Thread Rodney Topor
I've just started using PDO with PHP 5.1 and MySQL 5.0. Everything seems to work fine, except for one issue with the following example from the PHP manual. ?php try { $dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass); foreach ($dbh-query('SELECT * from FOO') as $row) {