码迷,mamicode.com
首页 > 数据库 > 详细

tp3.2数据库事务使用例子

时间:2019-06-26 12:10:28      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:cti   事物   使用   ror   提交   root   code   comm   tor   

   public function index(){
 6         //echo 111;
 7         $data[‘operator‘] = ‘Testss‘;
 8         M()->startTrans();
 9         $result = M(‘feehistory‘)->add($data);
10         $result1 = $result2 = true;
11         if(!empty($result)){
12             $regdelData[‘level‘] = ‘111‘;
13             $result1 = M(‘regdel‘)->add($regdelData);
14 
15             $regData[‘level‘] = ‘101‘;
16             $result2 = M(‘reg‘)->where("registryCode=‘13693536752-SJB-HUAX-12345678‘")->save($regData);
17 
18         }
19 
20         if(!empty($result) && !empty($result1) && !empty($result2) ){
21             M()->commit();    
22             //$this->success(‘事物提交‘,__ROOT__);
23             echo ‘事物提交‘;
24         }else{
25             M()->rollback();
26             //$this->error(‘事物回滚‘,__ROOT__);
27             echo ‘事物回滚‘;
28         }
29     }

tp3.2数据库事务使用例子

标签:cti   事物   使用   ror   提交   root   code   comm   tor   

原文地址:https://www.cnblogs.com/x-code-phper/p/11089055.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!