/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = SalaryMaster::find(); $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; } $query->andFilterWhere(['id' => $this->id, 'salary' => $this->salary, 'update_salary' => $this->update_salary, 'active' => $this->active]); $query->andFilterWhere(['like', 'employee', $this->employee]); return $dataProvider; }
public function actionSet_salary() { $id = Yii::$app->request->post('id'); $employee = Yii::$app->request->post('employee'); $columns = array("active" => '0'); Yii::$app->db->createCommand()->update("salary_master", $columns, "employee = '{$employee}' ")->execute(); $columns_active = array("active" => '1'); Yii::$app->db->createCommand()->update("salary_master", $columns_active, "id = '{$id}' AND employee = '{$employee}' ")->execute(); $rs = SalaryMaster::find()->where(['employee' => $employee, 'active' => 1])->one(); $json = array("salary" => $rs['salary']); echo json_encode($json); }