use app\index\controller\Modulecommon;
public function initialize(){
$this->pageinit = ['M'=>request()->module(),'C'=> 'Announcement','C_name'=>'公告通知','AP'=> '05','R'=> getrnd(9),'TREE_ID'=>25];
$this->treeid = 25;
$this->indexpage = '';
$this->model = new \app\oa\model\Announcement();
}公共控制器Modulecommon.php 简单写了一下public function save($id=""){
if(empty($id)){
$save = $this->model;
}else{
$save = $this->model::get($id);
}
Db::startTrans();
try {
$rs = $save->allowField(true)->save($_POST); //保存1
$am_id = $save->id;
$head['tree_id'] = $this->treeid;
$head['form_id'] = $id;
$head['step_id'] = $_POST['step_id'];
$head['is_sing'] = model('auth/Processstep')->where('id',$_POST['step_id'])->value('is_sing');
$head['result'] = $review_result;
$head['remark'] = isset($_POST['remark'])?$_POST['remark']:'';
$head['create_user'] = Session::get('user_name');
$rs = model('step_info');
$rs->save($head); //保存2
$head_id = $rs ->id;
$det['record_id'] = $head_id;
$det['user_id'] = $val;
$det['type'] = 1;
$det['remark'] = '';
Db::table('step_det')->insert($det); //保存3
Db::commit();
} catch (\Exception $e) {
Db::rollback();
$this->error('保存失败!');
}
$this->success('保存成功!');
}保存3 出错的时候,保存2回退了,保存1没有回退。这个问题有碰到过吗?
最佳答案