2011-04-07 13:58:48 0 评论 Yii 1.0 Boy.Lee

Yii 1.0 使用MySQL事务

{Code}

$transaction=$connection->beginTransaction();
try
{
    $connection->createCommand($sql1)->execute();
    $connection->createCommand($sql2)->execute();
    //.... other SQL executions
    $transaction->commit();
}
catch(Exception $e) // an exception is raised if a query fails
{
    $transaction->rollBack();
}