Thinkphp multi-table transaction details. Copy the code as follows: functionmakeAcquire ($ nUsers, $ nAwards) {update database $ tranDbnewModel (); $ tranDb-startTrans (); for ($ i0; $ isizeof ($ nUsers); $ I is as follows:
The code is as follows:
Function makeAcquire ($ nUsers, $ nAwards)
{
// Update the database
$ TranDb = new Model ();
$ TranDb-> startTrans ();
For ($ I = 0; $ I <sizeof ($ nUsers); $ I ++)
{
// Update The Acquire table
$ FlagAc = $ tranDb-> table ('acquire ')-> add ($ Acquire );
// Update the Users table
$ Where = array ('U _ id' => $ nUsers [$ I] ['U _ id']);
$ FlagU = $ tranDb-> table ('users')-> where ($ where)-> setInc ('U _ man_count ', 1 );
// Update the 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 ();
}
}
The pipeline code is as follows: function makeAcquire ($ nUsers, $ nAwards) {// update database $ tranDb = new Model (); $ tranDb-startTrans (); for ($ I = 0; $ I sizeof ($ nUsers); $ I...