I'm not sure if this is a related issue or a different one, but using the
following code I cannot catch the failing exception
try {
$db = Zend_Db::factory($config->db->adaptor, array('host' => 'localhost',
'username' =>'noexistant', 'password' => 'failme', 'dbname' => 'random'));
} catch (Exception $e) {
echo "caught an exception! <br />";
echo $e->getMessage();
exit;
}
I keep getting
Fatal error: Uncaught exception 'Exception' with message 'SQLSTATE[28000]
[1045] Access denied for user 'nonexistant'@'localhost' (using password:
YES)'
Without the database name I can successfuly catch an exception telling me
that the dbname key hasn't been filled in, but I seemingly cannot catch
the "failed to connect to db" exception
-Jude A.
On Sat, 10 Mar 2007 03:42:47 +0900, Bill Karwin <[EMAIL PROTECTED]> wrote:
That's a good point. Using the PDO adapters should be transparent, and
the Zend_Db classes should throw exceptions that extend
Zend_Db_Exception in all cases. So we need to catch PDOException in the
PDO adapters and re-throw as a more appropriate exception.
Can you please log a bug on this in JIRA, and I'll fix it. If you have
time to help me out, can you please identify the places in the PDO
adapter code where usage of PDO methods may throw PDOException and need
to be caught and re-thrown. I'll also make unit tests as part of the
fix.
Regards,
Bill Karwin
-----Original Message-----
From: Ralph Schindler [mailto:[EMAIL PROTECTED]
Sent: Friday, March 09, 2007 9:58 AM
To: Zend Framework General
Cc: Bill Karwin
Subject: [fw-general] Zend_Db Exception throwing?
Bill et. al.,
Out of curiosity, if I am using Zend_Db(_Adapter_Abstract) to execute
a
select object (query), should I be getting a Zend_Db_Exception or
derivative thereof when invalid sql is queried? Ie., i cannot catch
the
following:
try {
$s = $database_connection->select();
$s->from('valid_table')
->where('not_valid_column = ?', 'value');
$database_connection->fetchAll($s);
} catch (Zend_Db_Exception $e) {
echo "<pre>";
print_r($e);
die();
}
Currently, I see the database connection is throwing a PDOException
when
there is invalid sql.. like the above (not a valid column)
Is this the proper behavior?
Thanks,
Ralph