Home > Backend Development > PHP Tutorial > Detailed explanation of Thinkphp transaction operation examples

Detailed explanation of Thinkphp transaction operation examples

墨辰丷
Release: 2023-03-27 19:08:01
Original
1787 people have browsed it

This article mainly introduces the detailed explanation of Thinkphp transaction operation examples. Interested friends can refer to it. I hope it will be helpful to everyone.

The examples are as follows:

//开启mysql事务操作
$model = M();
$model->startTrans();
$flag=false;
$deal1 = M('ppdd')->where(array('id'=>$data_P['id'],'zt'=>'0'))->save($data_arr);
$deal2 = 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 ())));
$deal3 = M('jsbz')->where(array('id'=>$ppddxx['g_id']))->save(array('bj'=>'2'));
if($deal1 && $deal2 * $deal3){
 $flag=true;
}
if($flag){
 $model->commit();
}
else{
 $model->rollback();
 die("<script>alert(&#39;提交失败,请重新提交!&#39;);history.back(-1);</script>");
}
Copy after login

The above is the entire content of this article, I hope it will be helpful to everyone learning helps.


Related recommendations:

PHPHTMLPurifier prevents XSS attacks

PHPUse code to download files

##PHPUse code to download files

The above is the detailed content of Detailed explanation of Thinkphp transaction operation examples. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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