Thinkphp transaction operation instance (recommended) and thinkphp transaction
Example:
// Enable mysql transaction operations $ model = M (); $ model-> startTrans (); $ flag = false; $ deal1 = M ('ppdd ') -> where (array ('id' => $ data_P ['id'], 'zt '=> '0')-> save ($ data_arr ); $ deal = M ('tgbz')-> where (array ('id' => $ ppddxx ['P _ id']) -> save (array ('is _ dakuan '=> 1, 'bj' => '2 ', 'date _ hk '=> date ('Y-m-d H: I: s', time (); $ de_3 = M ('jsbz ') -> where (array ('id' => $ ppddxx ['G _ id'])-> save (array ('bj '=> '2 ')); if ($ deal1 & $ deal * $ de_3) {$ flag = true;} I F ($ flag) {$ model-> commit ();} else {$ model-> rollback (); die ("<script> alert ('submission failed, please submit again! '); History. back (-1); </script> ");}
The above Thinkphp transaction operation instance (recommended) is all the content shared by Alibaba Cloud xiaobian. I hope to give you a reference and support for the customer's home.