Hi Everyone,
I have a table and generate model and normal crud pages. While saving data using a form, I would like to save some data in another table as well.
I am writing the code as below. Does it follow commit roll back functionality?
Suppose my first model is saved and something went wrong and another sql query not executed. Then will it rollback in this scenario?
If no, How can I achieve it?
if($model->save())
{
if (Yii::app()->request->isAjaxRequest)
{
echo CJSON::encode(array(
'status'=>'success',
'div'=>"You successfully contributed fund to this event"
));
//Adding Debit Transaction into FundNano
$command1 = Yii::app()->db->createCommand('INSERT INTO fund_nano ( USER_ID, AMOUNT, AMT_INDICATOR, EVENT_ID, STATUS ) VALUES ( '.$model->USER_ID.', '.$model->AMOUNT.', "DR", '.$model->ORG_EVENT_ID.', "FUNDED AN EVENT" )');
//$command1->bindValue(':sum', $sum);
$nanoPass = $command1->execute();
//End
exit;
}
else
$this->redirect(array('view','id'=>$model->id));
}
}
Thank you in advance