thinkphp multi-table transactions detailed explanation_PHP tutorial

WBOY
Release: 2016-07-21 15:05:41
Original
946 people have browsed it

As shown below:

Copy code The code is as follows:

function makeAcquire($nUsers,$nAwards)
{
//Update database
$tranDb = new Model();
$tranDb->startTrans();
for($i = 0; $i < sizeof ($nUsers); $i++)
{
//Update table Acquire
$flagAc = $tranDb->table('Acquire')->add($acquire ; tranDb->table('Users')->where($where)->setInc('u_man_count',1);
//Update table 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();
}
}





http://www.bkjia.com/PHPjc/327670.html
www.bkjia.com

truehttp: //www.bkjia.com/PHPjc/327670.htmlTechArticle is as follows: Copy the code as follows: function makeAcquire($nUsers,$nAwards) { //Update database$ tranDb = new Model(); $tranDb-startTrans(); for($i = 0; $i sizeof($nUsers); $i...
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!