コード例 #1
0
ファイル: SiswaController.php プロジェクト: robebeye/isims
 /**
  * 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=$this->loadModel($id);
     
     		// Uncomment the following line if AJAX validation is needed
     		// $this->performAjaxValidation($model);
     
     		if(isset($_POST['Siswa']))
     		{
     			$model->attributes=$_POST['Siswa'];
     			if($model->save())
     				$this->redirect(array('view','id'=>$model->nis));
     		}
     
     		$this->render('update',array(
     			'model'=>$model,
     		));*/
     $model = $this->loadModel($id);
     $model2 = Keluarga::model()->findByPk($model->no_kk);
     $model3 = Ayah::model()->findByPk($model2->nik_ayah);
     $model4 = Ibu::model()->findByPk($model2->nik_ibu);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Siswa'])) {
         $model4->attributes = $_POST['Ibu'];
         $model3->attributes = $_POST['Ayah'];
         $model2->attributes = $_POST['Keluarga'];
         $model->attributes = $_POST['Siswa'];
         $valid = $model->validate();
         $valid = $model4->validate() && $valid;
         $valid = $model3->validate() && $valid;
         $valid = $model2->validate() && $valid;
         if ($valid) {
             $model4->save();
             $model3->save();
             $model2->save();
             if ($model->save()) {
                 $this->redirect(array('view', 'id' => $model->nis));
             }
         }
     }
     $this->render('update', array('model' => $model, 'model2' => $model2, 'model3' => $model3, 'model4' => $model4));
 }
コード例 #2
0
ファイル: IbuController.php プロジェクト: robebeye/isims
 /**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Ibu::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }