/** * save the post's account (*3) */ public function saveAccount() { if ($this->Person[0] == 'selected') { $data_id_slice = array_slice($this->Person, 1); } else { $data_id_slice = $this->Person; } if ($data_id_slice != '') { $data_id = implode(",", $data_id_slice); } else { $data_id = ''; } // $rows = (new \yii\db\Query()) // ->select(["CONCAT(em.EMP_NM, ' ',em.EMP_NM_BLK) AS full_name"]) // ->from('dbm001.user us') // ->leftjoin('dbm002.a0001 as em','em.EMP_ID = us.EMP_ID') // ->where(['us.id' => $data_id_slice]) // ->all(); // foreach ($rows as $key => $value) { // # code... // $val[] = $value['full_name']; // } // $data_fullname = implode(',',$val); $transaction = Notulen::getDb()->beginTransaction(); try { $execute = Yii::$app->db_widget->createCommand()->update('m0002', ['USER_ID' => $data_id], 'NOTULEN_ID="' . $this->NotulenId . '"')->execute(); $execute2 = Yii::$app->db_widget->createCommand()->update('m0001', ['USER_ID' => $data_id], 'id="' . $this->NotulenId . '"')->execute(); // ...other DB operations... $transaction->commit(); } catch (\Exception $e) { $transaction->rollBack(); throw $e; } // # code... // $pc = NotulenModul::find()->where(['NOTULEN_ID'=>$this->NotulenId])->one(); // $pc->USER_ID = ; // $pc->save(); }
/** * Creates a new Notulen model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($start, $end) { $model = new Notulen(); // $model->scenario = Notulen::SCENARIO_NOTE; $model_modul = new NotulenModul(); if ($model->load(Yii::$app->request->post())) { $transaction = Notulen::getDb()->beginTransaction(); try { $model->start = $start; $model->end = $end; $model->CREATE_BY = self::Get_profile()->id; $model->CREATE_AT = date("Y-m-d H:i:s"); $model->save(); $model_modul->NOTULEN_ID = $model->id; $model_modul->save(); // ...other DB operations... $transaction->commit(); } catch (\Exception $e) { $transaction->rollBack(); throw $e; } return $this->redirect(['review', 'id' => $model->id]); } else { return $this->renderAjax('create', ['model' => $model, 'data_modul' => self::getary_modul(), 'data_emp' => self::get_aryEmploye()]); } }