One data to two tables

Dear All,

I am having a slight hiccup with developing an application.

I am accessing update page to create an "Amendments" module. When a user update a particular record in the system, I would like to track it. Thus pushing data on afterSave.

I have tried the code below to no avail. Searched online but I am still stuck on this problem. It returns no error and I tried creating conditions for testing purposes, the save() has no problems.

Any pointers from Yii users here?

	protected function afterSave()


		//print_r ($this->id);

		Amendments::model()->joborder_id = $this->id;



All assistance are greatly appreciated.

I think you want rather do sth like this:

	protected function afterSave()


		//print_r ($this->id);

		$model = new Amendments();

                $model->joborder_id = $this->id;


                // always call parent implementation - good programming pattern when extending classes



You should also check if $model->save() does not return FALSE (meaning: object failed validation)

…and if you want to save same data as in main table, add

$model->attributes = $this->attributes;

Hi Maciej Lizewski,

I have tried the code and it is working fine. I have managed to save in "Amendments" table without a problem.

Thank you for the assistance and guidance.