예제 #1
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = new Pregunta();
     $b = new Metrica();
     $c = new OpcionRespuesta();
     //$model=$this->loadModel($id);
     //$b=$this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model, $b, $c);
     $model = $this->loadModel($id);
     $c = OpcionRespuesta::model()->findByAttributes(array('id_pregunta' => $model->id_pregunta));
     //$b=$this->loadModel($id);
     if (isset($_POST['Pregunta'], $_POST['Metrica'], $_POST['OpcionRespuesta'])) {
         $model->attributes = $_POST['Pregunta'];
         $b->attributes = $_POST['Metrica'];
         $c->attributes = $_POST['OpcionRespuesta'];
         $c->id_pregunta = $model->id_pregunta;
         $b->setIsNewRecord(false);
         if ($model->save() && $b->update() && $c->update) {
             $this->redirect(array('view', 'id' => $model->id_pregunta));
         }
     }
     $this->render('update', array('model' => $model, 'b' => $b, 'c' => $c));
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return OpcionRespuesta the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = OpcionRespuesta::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }