╃巡洋艦㊣ 2011-03-24 11:14:57 5225次浏览 7条回复 0 0 0
$model=Post::model();
$transaction=$model->dbConnection->beginTransaction();
try
{
  // find and save are two steps which may be intervened by another request
  // we therefore use a transaction to ensure consistency and integrity
  $post=$model->findByPk(10);
  $post->title='new post title';
  $post->save();
  $transaction->commit();
}
catch(Exception $e)
{
  $transaction->rollBack();
}
您需要登录后才可以回复。登录 | 立即注册