Php yii在插入时捕获CDBEException

Php yii在插入时捕获CDBEException,php,yii,Php,Yii,我想捕获插入时的db异常(如外键或重复异常) 但是命令在我捕获它之前抛出一个异常 ...\framework\db\CDbCommand.php(358) 346 { 347 if($this->_connection->enableProfiling) 348 Yii::endProfile('system.db.CDbCommand.execute('.$this->getText().$par.')

我想捕获插入时的db异常(如外键或重复异常)

但是命令在我捕获它之前抛出一个异常

...\framework\db\CDbCommand.php(358)

346         {
347             if($this->_connection->enableProfiling)
348                 Yii::endProfile('system.db.CDbCommand.execute('.$this->getText().$par.')','system.db.CDbCommand.execute');
349 
350             $errorInfo=$e instanceof PDOException ? $e->errorInfo : null;
351             $message=$e->getMessage();
352             Yii::log(Yii::t('yii','CDbCommand::execute() failed: {error}. The SQL statement executed was: {sql}.',
353                 array('{error}'=>$message, '{sql}'=>$this->getText().$par)),CLogger::LEVEL_ERROR,'system.db.CDbCommand');
354 
355             if(YII_DEBUG)
356                 $message.='. The SQL statement executed was: '.$this->getText().$par;
357 
358             throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
359                 array('{error}'=>$message)),(int)$e->getCode(),$errorInfo);
360         }
361     }

它抛出了什么异常?请提供带有切出和完整异常消息的真实示例。目前,它抛出了一个重复的异常。如果我使用command.execute($insertQuery),我也会得到同样的结果。我需要找到一种方法,使命令不引发异常,只返回异常,我将自己处理异常。它引发了什么异常?请提供带有切出和完整异常消息的真实示例。目前,它引发了重复的异常。如果我使用command.execute($insertQuery),我也会得到同样的结果。我需要找到一种方法,使命令不抛出异常,只返回异常,我将自己处理异常。
...\framework\db\CDbCommand.php(358)

346         {
347             if($this->_connection->enableProfiling)
348                 Yii::endProfile('system.db.CDbCommand.execute('.$this->getText().$par.')','system.db.CDbCommand.execute');
349 
350             $errorInfo=$e instanceof PDOException ? $e->errorInfo : null;
351             $message=$e->getMessage();
352             Yii::log(Yii::t('yii','CDbCommand::execute() failed: {error}. The SQL statement executed was: {sql}.',
353                 array('{error}'=>$message, '{sql}'=>$this->getText().$par)),CLogger::LEVEL_ERROR,'system.db.CDbCommand');
354 
355             if(YII_DEBUG)
356                 $message.='. The SQL statement executed was: '.$this->getText().$par;
357 
358             throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
359                 array('{error}'=>$message)),(int)$e->getCode(),$errorInfo);
360         }
361     }