/** * Creates a new Divisions model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Divisions(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Updates an existing Hospitals model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdateData($id) { Yii::$app->dbTest->createCommand("CALL InsightsIndicatorsUpdate({$id}, 201501, 201509)")->execute(); if ($rows = Yii::$app->dbTest->createCommand('select afr.*,o.nazwa from afr_indicators afr join oddzial o on o.id=afr.id_oddzial where afr.id_szpital = ' . $id)->queryAll()) { foreach ($rows as $line) { $division = new Divisions(); foreach (array_keys($line) as $key) { if ($key !== 'id') { $division->{$key} = $line[$key]; } } $division->save(); } } return $this->redirect(['divisions/index', 'id_hospitals' => $id]); }