Using Two Tables In Model

Hello Friends.

         I need to use two two table in a single model how can i use it help me out plz...


2)Maturitydate… these are the two tables.

Go through to this Wiki

I used this wiki Balu… but when in click create button the page is not loaded it will not be saved… how can i save those values in the both tables.

Here is my controller…

public function actionCreate()


		$model=new Add;

		$maturityModel_1 = new maturity;  // Maturity Model

    //$addressModel_2 = new Address;  // Address Model

		// Uncomment the following line if AJAX validation is needed

		// $this->performAjaxValidation($model);






			 $valid=$maturityModel_1->validate() && $valid;

              $valid=$model->validate() && $valid;















why can’t you use two different models and the controller similar to what you have? I’m sure it’s feasible but not really ideal to put it in the same model. It would also make it easier for saving, updating, searching etc. if you use two different models.

I didnt tried that skworden can u please help out with that example or related link…

Try this

If you still have trouble if that is the controller action above leave it if not post the correct controller action. Also, you will need to post your form and two models for anyone to help you. There isn’t enough info for anyone to help so please be more descriptive next time. It will help us help you faster.

@skworden i Finished the create part… now i cant update those forms… in this Try this wiki there is no updation… so help out for that