Toda vez que tento deletar um registro esta dando um erro no alert:
<h1>CDbException</h1>
<p>CDbCommand falhou ao executar o comando SQL: SQLSTATE[HY000]: General error: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`eurekasos`.`opcoes`, CONSTRAINT `opcoes_ibfk_1` FOREIGN KEY (`perguntas_id`) REFERENCES `perguntas` (`id`)) (D:\websites\sos\framework\db\CDbCommand.php:316)</p><pre>#0 D:\websites\sos\framework\db\ar\CActiveRecord.php(1647): CDbCommand->execute()
#1 D:\websites\sos\framework\db\ar\CActiveRecord.php(1113): CActiveRecord->deleteByPk('1')
#2 D:\websites\sos\protected\controllers\PerguntasController.php(137): CActiveRecord->delete()
#3 D:\websites\sos\framework\web\actions\CInlineAction.php(57): PerguntasController->actionDelete()
#4 D:\websites\sos\framework\web\CController.php(300): CInlineAction->run()
#5 D:\websites\sos\framework\web\filters\CFilterChain.php(133): CController->runAction(Object(CInlineAction))
#6 D:\websites\sos\framework\web\filters\CFilter.php(41): CFilterChain->run()
#7 D:\websites\sos\framework\web\CController.php(1088): CFilter->filter(Object(CFilterChain))
#8 D:\websites\sos\framework\web\filters\CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))
#9 D:\websites\sos\framework\web\filters\CFilterChain.php(130): CInlineFilter->filter(Object(CFilterChain))
#10 D:\websites\sos\framework\web\CController.php(283): CFilterChain->run()
#11 D:\websites\sos\framework\web\CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)
#12 D:\websites\sos\framework\web\CWebApplication.php(328): CController->run('delete')
#13 D:\websites\sos\framework\web\CWebApplication.php(121): CWebApplication->runController('perguntas/delet...')
#14 D:\websites\sos\framework\base\CApplication.php(155): CWebApplication->processRequest()
#15 D:\websites\sos\index.php(13): CApplication->run()
#16 {main}</pre>
Como faço para deletar o resgistro 1 > N
public function actionDelete()
{
if(Yii::app()->request->isPostRequest)
{
// we only allow deletion via POST request
$this->loadModel()->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index'));
}
else
throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
}
Valew