tp3.2 database transaction usage example

   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 ( 'being filed', __ ROOT__);
23 is echo 'being filed';
24} the else {
25 M () -> ROLLBACK ();
26 is // $ this-> error ( 'something back roll ', __ ROOT__);
27 echo' things rollback ';
28}
29}

Guess you like

Origin www.cnblogs.com/x-code-phper/p/11089055.html