标签:== php cep sprint tsql not tran except merge
这是我写的一段代码,里面通过PHP异常功能,实现报错时显示出错代码所在行。当使用者操作出错时,截图给我,我可以很快得去追踪和排查错误!
public function added_business_submit(){ try{ extract($_POST); if(‘‘==$title) self::json(0,sprintf(ERROR_EMPTY,‘工单标题‘)); if(‘‘==$is_trusteeship) self::json(0,sprintf(ERROR_EMPTY,‘服务器类别‘)); if(‘‘==$eqroom_id) self::json(0,sprintf(ERROR_EMPTY,‘所在机房‘)); M()->startTrans(); $com_info = M(‘company‘)->where(array(‘com_qyuserid‘=>$com_qyuserid))->find(); $com_id = $com_info[‘com_id‘]; $com_name = $com_info[‘com_name‘]; if(empty($com_info)) throw new Exception(ERROR_NOTFOUND_USER); $data = array( ‘com_id‘ => $com_id, ‘com_name‘ => $com_name, ‘type‘ => 1, ‘step‘ => 1, ‘poster‘ => self::$user[‘name‘], ‘posttime‘ => self::$datetime, ‘eqroom_name‘ => D(‘EquipRoom‘)->get_eqroom_name($eqroom_id), ); $data = array_merge($data,$_POST); $agent_id = M(‘working_agent‘)->add($data); if(false===$agent_id) throw new Exception(ERROR_SUBMIT); $result = D(‘StepLogAgent‘)->next_step($agent_id,$remark); if(false===$result) throw new Exception(ERROR_SUBMIT); }catch(Exception $e){ M()->rollback(); $this->exception_handle($e); } M()->commit(); self::json(1,SUCCESS_SUBMIT); } private function exception_handle(Exception $e){ $msg = $e->getMessage(); $line = $e->getLine(); //**/print_r($e); echo M()->getLastSql(); $name = self::$user[‘name‘]; $time = self::$datetime; $sql = M()->getLastSql(); $log = $time." ".$name.":{$msg}({$line}) {$sql}"; self::mylog($log,‘Agent‘); self::json(0,"{$msg}({$line})"); }
标签:== php cep sprint tsql not tran except merge
原文地址:http://www.cnblogs.com/chy1000/p/6879850.html