Created
September 28, 2022 09:52
-
-
Save raihan-uddin/5bb1926ed4feb9d3f60ffa8ae2779ed7 to your computer and use it in GitHub Desktop.
yii1 transection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$transaction = Yii::app()->db->beginTransaction(); | |
try { | |
if (!$model->save()) { | |
throw new Exception('Model cannot be saved.'); | |
} | |
if (!$anothermodel->save()) { | |
throw new Exception('Anothermodel cannot be saved.'); | |
} | |
$transaction->commit(); | |
} catch (Exception $e) { | |
$transaction->rollback(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment