Do I need a try-catch block for PDO?

Hello. I'm thinking of writing something like this:

<?php


try {


	$stmt = Yii::app()->db->getPdoInstance()->prepare($sql);


	// Do something.


catch(PDOException $e) {


	throw new CException($e->getMessage());


}


My questions are:

  1. Is this the correct way to throw a Yii CException?

  2. Do I need the try-catch block at all? Or will Yii automatically catch a PDOException and complain?

Thanks.

No need to re-throw the exception unless you want to do something about it (such as rollback changes in a transaction). Yii will catch and handle those uncaught exceptions.

Thanks. Yii rocks.