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
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
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
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 =
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);
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
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) {