/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $profile = Yii::$app->getUserOpt->profile_user(); //componen $id = $profile->id; $query = Notulen::find()->where('USER_ID like "%' . $id . '%"')->orwhere(['CREATE_BY' => $id])->orderby(['start' => SORT_DESC]); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'start' => $this->start, 'end' => $this->end, 'MODUL' => $this->MODUL, 'STATUS' => $this->STATUS, 'CREATE_AT' => $this->CREATE_AT, 'UPDATE_AT' => $this->UPDATE_AT]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'USER_ID', $this->USER_ID])->andFilterWhere(['like', 'CREATE_BY', $this->CREATE_BY])->andFilterWhere(['like', 'UPDATE_BY', $this->UPDATE_BY]); return $dataProvider; }
/** * 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(); }
/** * Finds the Notulen model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Notulen the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Notulen::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }