I have to update two tables from one form. I have two tables TestA and TestB. So how can I update two tables where TestB.testid=TestA.testid. Both the tables are populated. I need to update TestB based on the id of TestA. Below is the actionUpdate of TestA.
When I run the application, a new entry is created in TestB instead of updating the existing one. How can I pass the id to update the row in table TestB
public function actionUpdate($id) { $model_A=new TestA; $model_B=new TestB; $model=$this->loadModel($id); if(isset($_POST['TestA'])&&isset($_POST['TestB'])) { $model_A->attributes=$_POST['TestA']; $model_B->attributes=$_POST['TestB']; $model_B->name="test"; $model_A->save(); $model_B->save(); $this->render('update',array( 'model'=>$model, )); }
When I run the application, a new entry is created in TestB instead of updating the existing one. How can I pass the id to update the row in table TestB