I am very new to Yii. I was trying something like this--
public function actionCreate()
{
$a=new Tblcompany;
$b= new Tblusergroup;
$transaction= Yii::app()->db->beginTransaction();
try{
if(isset($_POST['Tblcompany']))
{
$a->attributes=$_POST['Tblcompany'];
if($a->save()){
$b->company_code= $a->company_code;
$b->usergroup_code='Admin';
$b->save();
$transaction->commit();
$this->redirect(array('view','id'=>$a->company_code));
}
}
$this->render('create',array(
'a'=>$a,
'b'=>$b,
));
}catch(Exception $error){
$transaction->rollback();
}
}
don't know why no data is being saved in tblusergroup. Although data is perfectly added in tblcompany..Kindly help please :/