yii transcation


$transaction = Yii::app()->db->beginTransaction();            //事務處理
try{
        $model_1->save(true);
        $model_2->save(false);
        $transaction->commit();                                            //事務commit

}catch(Exception $e){
        $transaction->rollback();                                            //有異常時,SQL處理回滾
        throw new CHttpException(500,"sth wrong");
}

你可能感兴趣的:(yii,transcation)