Home > Backend Development > PHP Tutorial > thinkphp,事务回滚解决办法

thinkphp,事务回滚解决办法

WBOY
Release: 2016-06-13 13:44:18
Original
1408 people have browsed it

thinkphp,事务回滚
function test(){
$withdraw = M('Withdraw');
$withdraw->startTrans();

$data['agent_id']=1;
$data['money']=1222;

$withdraw->add($data);

$withdraw->rollback();
}

------解决方案--------------------
你那数据应该没插进去吧,$withdraw->rollback();回滚了
------解决方案--------------------
$withdraw->startTrans();
$withdraw = M('Withdraw');
$withdraw->add($data);
if(成功){
$withdraw->commit();
}else{
$withdraw->rollback();
}

////////////////////////////////////

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