[SOLVED] Problem to insert field from one table to other table

i hav two tables, there are table krs and table nilai1.

when i save the model of table krs, i hope the id(PK) of table krs can also be inserted to id_krs (table nilai1).

The structure of tables :

table krs

id(PK) | attribute1 | attribute2 |

table nilai1

id(PK) | id_krs(FK) | attribute3 | attribute4 |

Here the modification of KrsController.php

public function actionCreate()


            $model=new Krs;

            $model2=new Nilai1;












                        //print_r($model->getErrors()); die();





                        throw new CException($model->getErrors());





                catch(CException $er){









but, the result not like i want, not saving anything to the tables…

Somebody can help me???

what is the output of



integer value, i’m make id as auto_increment

maybe something wrong with my code?

So if Nilai1 BELONGS_TO Krs you can, for example use EAdvancedARBehavior to simplify things a little bit!

Anyway, from what you’ve provided us, it all seems to be ok, so I would guess that $transaction->rollBack() is called. Check the input again and make sure that commit() is called!


i have solved my problem

that i was remove the $transaction command also the try and catch

then i was add some code thats for identify the all fields of table nilai1

and now working

Hi sir,

Can u please tell how u will solved this , i have the same problem

please please reply me sir