diff --git a/php/bullshitClass.php b/php/bullshitClass.php index ef11c45229c30cc52c85cd230f3bd7d9c1fc43a1..6aff38c0ac321317b400a9ee2f80f48853a3658c 100644 --- a/php/bullshitClass.php +++ b/php/bullshitClass.php @@ -22,4 +22,24 @@ class bullshitClass // 2.给用户的账户加钱 } } + + /** + * 示例二:事务的处理 + * + */ + public function demo2() + { + Db::startTrans(); + try { + // 逻辑1 + // 逻辑2 + // ... + return true; + Db::commit(); + } catch (Exception $e) { + return false; + Db::rollback(); + + } + } } \ No newline at end of file