标签:upd sage 回滚 回滚事务 ESS false json job 审核
// 启动事务 Db::startTrans(); try { $save = [ ‘wx‘=>$data[‘wx‘], ‘nickname‘=>$data[‘nickname‘], ‘sex‘=>$data[‘sex‘], ‘birth_date‘=>$data[‘birth_date‘], ‘email‘=>$data[‘email‘], ‘address‘=>$data[‘address‘] ]; $ok = Db::name(‘User‘)->where([‘id‘=>$user_id])->update($save); if($ok!==false){ //自定义字段保存 $field_save = model(‘api/v1/User‘)->field_list_save($data,$user_id); if($field_save[‘code‘]!=200){ throw new \Exception($field_save[‘msg‘]); } //获取职位所属分类id $category = explode(‘/‘,$job[‘category‘]); $tid = $category?end($category):‘‘; $message_data = [ ‘tid‘=>$tid, ‘pid‘=>$data[‘id‘], ‘add_user_id‘=>$user_id ]; $insert = Db::name(‘JobMessage‘)->insert($message_data); if($insert){ $json = [‘code‘=>200,‘msg‘=>‘申请成功,请等待后台审核‘]; }else{ throw new \Exception(‘申请失败,请联系管理员‘); } } // 提交事务 Db::commit(); } catch (\Exception $e) { // 回滚事务 Db::rollback(); $json = [‘code‘=>-200,‘msg‘=>$e->getMessage()]; } return $json;
标签:upd sage 回滚 回滚事务 ESS false json job 审核
原文地址:https://www.cnblogs.com/cbywan/p/10311336.html