I have a problem with de CDbException. In my DB I have a UNIQUE filder, but when (in m application) I create a new cliente with the same UNIQUE filder registred show me an error like this:
CDbCommand falhou ao executar o comando SQL: SQLSTATE …
I solved this problem with the rules at my model cliente, but I want if I forget handling this to show in user’s view the helpfull form, and after show to the user, I want to send to me an email solving this problem.
For CHttpException has errorhandler; has any to CDbException?
How about adding validation rule for that particular unique field. For example:
public function rules()
{
return array(
..............................
array('user_id', 'unique'),
..............................
);
}
Then Yii won’t complain or put any CDbException errors under your application.log. Instead it will present user with friendly error message like below: