$transaction = Yii::app()->db->beginTransaction();
try
{
if (!$model1->save())
throw new Exception('Failed to save model 1');
if (!$model2->save())
throw new Exception('Failed to save model 2');
// etc...
$transaction->commit();
// You can handle success messages and redirection here
}
catch (Exception $ex)
{
$transaction->rollback();
}
What Keith said plus see these couple of official documentation on this: first (generic transaction SQL usage) and second (AR with transactions. probably closer to what you want).