How To Catch Pdo Exception

In one of my models, I have a method to test a PDO connection. I use a try and catch to catch the exception and then I return the connection status (true or false). My try and catch is not working because Yii catches the PDO exception first and uses its own handler to handle the exception.

How can I prevent Yii from handling this exception?

My code:

public static function getConnectionStatus($connectionString, $user, $pwd)



         $myConnect = new PDO($connectionString, $user, $pwd);

         $myConnect = null;

         return true;


    catch (Exception $e){

        // Never reach this point.  Yii handles the exception?!  How do I prevent Yii from doing this?

        return false;



Yii should only catch unhandled exceptions. Maybe the one you are trying to catch is not derived from the Exception class.

I changed it to catch PDOException and it started working. It’s strange because PDOException is derived from Exception. I am still not sure what was wrong with my code above.

Thanks for the help.