Пример #1
0
 /**
  * 核心逻辑
  */
 public final function execute()
 {
     $this->ret['data'] = array();
     try {
         $this->_init();
         //初始化基本环境
         $this->__prepare();
         //针对下游的支持函数
         $this->__before();
         //针对执行之前的钩子,这个钩子提供个具体的框架通用逻辑使用,如用户登陆判断 权限验证等
         $data = $this->__execute();
         //实际执行业务逻辑,并返回数据的函数
         empty($data) && ($data = array());
         $this->ret['data'] = array_merge($this->ret['data'], $data);
         $this->__after();
         //针对执行之后的钩子,这个钩子是提供给具体框架实现通用业务逻辑使用
         $this->__complete();
         //完成基本的收尾工作
         $this->ret['flag'] = self::SUCC;
     } catch (Blue_Exception_Break $e) {
         //啥都不干
         //只是用于跳出逻辑
     } catch (Blue_Exception_Redirect $e) {
         $this->ret['redirect'] = $e->getUrl();
         Core_Log::debug($e->getMessage(), $e->getArgv());
         $this->ret['flag'] = self::SUCC;
     } catch (Blue_Exception_Fatal $e) {
         $this->ret['msg'] = 'system error';
         $this->ret['flag'] = self::FAIL;
         $this->_message('系统错误');
     } catch (Blue_Exception_Warning $e) {
         $this->ret['msg'] = $e->getMessage();
         $this->ret['data'] = $e->getArgv();
         $this->ret['flag'] = self::FAIL;
         $this->_message($e->getMessage());
     } catch (Blue_Exception $e) {
         $this->ret['msg'] = 'system error';
         $this->ret['flag'] = self::FAIL;
         $this->_message('系统错误');
         //$this->ret['msg'] = $e->getMessage();
         //$this->ret['data'] = $e->getArgv();
     }
     //过滤掉NULL为空字符串
     $this->_filterNullToString();
     //输出
     $this->_output();
 }
Пример #2
0
 /**
  * * 运行完成后的回调
  * *
  * * 1. log中增加 时间消耗、内存消耗 统计
  * * 2. 输出日志
  * */
 public static function execShutdownCallback()
 {
     Core_Timer::endRecord();
     Core_Log::debug('php status', array('cost' => Core_Timer::getResult(), 'mem' => memory_get_peak_usage(TRUE)));
 }
Пример #3
0
 /**
  * 执行实际的SQL
  *
  * @param string $sql 执行的SQL语句
  *
  * @return mixed 
  */
 public function query($sql)
 {
     $result = $this->ins->query($sql);
     Core_Log::debug("database query", array('sql' => $sql));
     if ($result === FALSE) {
         throw new Blue_Exception_Fatal("DB Execute Error", array('msg' => $this->ins->error, 'errno' => $this->ins->errno, 'sql' => $sql));
     }
     return $result;
 }