I have two model and wanna commit and roleback this. The db is oracle.
if($model->validate() && $channels->validate()) {
/*declarate the transaction*/
$transaction = $model->dbConnection->beginTransaction();
try {
/*save the campaign model and commit it*/
$model->save();
/*model pk save to channels fk*/
$channels->CAMPAIGN_ID = $model->CAMPAIGN_ID; //error why dont have the id
/*channels.campaign_id is a fk*/
/*save the channels model and commit it*/
$channels->save();
/*if no error redirect to view*/
$this->redirect(array('view','id'=>$model->CAMPAIGN_ID));
} catch (Exception $e) {
$transaction->rollback();
Yii::app()->user->setFlash('error', "{$e->getMessage()}");
$this->refresh();
}
}
If i use the oracle sequence.nextval, return error: fk contrains.
Any idea?