Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement multiple tables and transactions in thinkphp

Shulou Source: shulou.com Published: 2022-06-03 06:23:11 11月16日 Update

This article mainly introduces how to achieve multiple tables and transactions in thinkphp. It is very detailed and has a certain reference value. Friends who are interested must read it!

As follows:

Function makeAcquire ($nUsers,$nAwards)

{

/ / Update the database

$tranDb = new Model ()

$tranDb- > startTrans ()

For ($I = 0; $I

< sizeof($nUsers); $i++) { //更新表Acquire $flagAc = $tranDb->

Table ('Acquire')-> add ($acquire)

/ / Update table Users

$where = array ('utiliti' = > $nUsers [$I] ['upliid'])

$flagU = $tranDb- > table ('Users')-> where ($where)-> setInc

$where = array ('aroomidservant = > $nAwards [$I] [' aroomid'])

$flagA = $tranDb- > table ('Award')-> where ($where)-> setDec

}

If ($flagAc & & $flagU & & $flagA)

{

$tranDb- > commit ()

}

Else

{

$tranDb- > rollback ()

}

}

These are all the contents of the article "how to implement multiple tables and transactions in thinkphp". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Updates transactions content articles value interests guys buddies data databases more knowledge industry information information channels channels references help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker MariaDB vpn Shulou Tech Info Xiaomi