protected function findModel($id)
 {
     if (($model = Event::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #2
0
 public function actionParsingLog($id)
 {
     $mod = LogUpload::findOne($id);
     $type = $mod->type;
     $keys = \yii\helpers\Json::decode($mod->keys);
     $values = \yii\helpers\Json::decode($mod->values);
     $modelAttribute = new Event();
     $not = Util::excelNot();
     foreach ($values as $value) {
         if ($type == LogUpload::TYPE_INSERT) {
             $model = new Event();
         } else {
             $model = Event::findOne($value['id']);
         }
         foreach ($keys as $v) {
             $model->{$v} = $value[$v];
         }
         $e = 0;
         if ($model->save()) {
             $model = NULL;
             $pos = NULL;
         } else {
             $error[] = \yii\helpers\Json::encode($model->getErrors());
             $e = 1;
         }
     }
     if ($error) {
         foreach ($error as $err) {
             if ($err) {
                 $er[] = $err;
                 $e += 1;
             }
         }
         if ($e) {
             $mod->warning = \yii\helpers\Json::encode($er);
             $mod->save();
             echo '<pre>';
             print_r($er);
         }
     }
 }