yii2: Update values in two tables using single controller action?
问题 I have two tables table1 and table2 and I am trying to update row in these two table.I have same values on both table but id is different so i tried like this, my controller, public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model- >validate()) { Employee::find()->where(['Id' => $id])->one()->update(); User::find()->where(['User_id' =>$id])->one()->update(); if ( $model->save()) { return $this->redirect(['index']); } } else {