Home > php教程 > php手册 > thinkphp 多表 事务详解

thinkphp 多表 事务详解

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:48:02
Original
1487 people have browsed it

如下所示:

复制代码 代码如下:


function makeAcquire($nUsers,$nAwards)
    {
     //更新数据库
     $tranDb = new Model();
     $tranDb->startTrans();
     for($i = 0; $i      {
      //更新表Acquire
      $flagAc = $tranDb->table('Acquire')->add($acquire);
      //更新表Users
      $where = array('u_id'=>$nUsers[$i]['u_id']);
      $flagU = $tranDb->table('Users')->where($where)->setInc('u_man_count',1);
      //更新表Award
      $where = array('a_id'=>$nAwards[$i]['a_id']);
      $flagA = $tranDb->table('Award')->where($where)->setDec('a_count',1);
     }
     if($flagAc && $flagU && $flagA)
     {
      $tranDb->commit();
     }
     else
     {
      $tranDb->rollback();
     }
    }


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Why thinkphp has better performance than laravel?
From 1970-01-01 08:00:00
0
0
0
ThinkPHP Why use composer?
From 1970-01-01 08:00:00
0
0
0
thinkphp versions supported by php6
From 1970-01-01 08:00:00
0
0
0
thinkphp upload files
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template