当前位置:Gxlcms > PHP教程 > thinkphp,事务回滚解决办法

thinkphp,事务回滚解决办法

时间:2021-07-01 10:21:17 帮助过:24人阅读

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();
}

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

人气教程排行