M()->startTrans(); $payOb=D('SPayLog'); if($payOb->create($_POST)){ $balance_old=M($this->table)->where(array('id'=>$member_id))->getField('balance'); $_POST['balance']=$pay+$balance_old; $_POST['mid']=$member_id; $_POST['uid']=session('uid'); $_POST['process_type']=1; $_POST['amount']=$pay; $_POST['created_at']=date("Y-m-d H:i:s",time()); //數據入表 $re=$payOb->add($_POST); if(!$re){ M()->rollback(); $this->error("操做失敗"); } $re_member=D($this->table)->editData(array('id'=>$member_id),array('balance'=>$_POST['balance'])); if(!$re_member){ M()->rollback(); $this->error("操做失敗"); } M()->commit(); } $this->success('操做成功!',$return_url)
若是之後發現有更好的寫法,再更吧。如今先記錄一下。session