If mysql connection is successful

I need to check if a mysql connection has been successful, otherwise return something else instead of it spitting out an error message (see error message below). Is there any way to do this?


$db3 = new Zend_Db_Adapter_Pdo_Mysql(array(
'host' => 'xxx',
'username' => 'xxx',
'password' => 'xxx',
'dbname' => 'xxx'

I have tried
if(!$db3->getConnection()) { return $this->responseError('No no no!'); }​

SQLSTATE[HY000] [1045] Access denied for user ....​


XenForo developer
Staff member
You will want to wrap your getConnection() line in a try-catch (catching Zend_Db_Exception). If you catch an exception, it failed. You can see an example in XenForo_Install_Controller_Instal::_testConfig().