try{
//开启事物
Db::startTrans();
//方量表
$fl_data = [
'qddj' => null,
'fhl' => $post['fangliang'],
'kzyy' => null,
'UserName' => '管理员',
'EditDateTime' => date('Y-m-d H:i:s'),
'ContractId' => $post['ids'],
'Zbid' => 1
];
Db::table('ContractControlfhl')->insert($fl_data);
//时间表
$time_data = [
'qddj' => null,
'tgsj' => $post['times'],
'kzyy' => 'null',
'UserName' => '管理员',
'EditDateTime' => date('Y-m-d H:i:s'),
'ContractId' => $post['ids'],
'Zbid' => 1
];
Db::table('ContractControlfhsj')->insert($time_data);
// 提交事务
Db::commit();
}catch(\Exception $e){
//回滚事务
Db::rollback();
return json(array('code'=>1,'msg'=>$e->getMessage()));
}
ThinkPHP 5 数据回滚
最新推荐文章于 2023-05-06 17:14:02 发布