Example #1
0
 /**
  * 设置请求返回状态,默认为200
  *
  * @param int   $status 状态码
  * @param array $param 请求传递的参数
  * @param bool  $error 是否判定为错误
  */
 public function status($status, $param = [], $error = true)
 {
     \header('Status: ' . $status);
     if ($status >= 400 && $error) {
         self::$taskSuccess = false;
         Error::fatal($status, '', $param);
     }
 }
Example #2
0
 /**
  * 生成PDO实例
  *
  * @throws \ErrorException
  * @return string
  */
 private function generateDsn()
 {
     $config = $this->config;
     if (\method_exists($this, $config['type'])) {
         try {
             return \call_user_func_array([$this, $config['type']], [$config]);
         } catch (\PDOException $e) {
             Error::fatal($e->getMessage(), $e->getCode());
         }
     } else {
         throw new \ErrorException('数据库类型 [' . $config['type'] . '] 不存在');
     }
 }
Example #3
0
 /**
  * 输出解析中的错误
  *
  * @param $code
  * @param $msg
  */
 protected function error($code, $msg)
 {
     Error::fatal($code, $msg . ' [in file: ' . $this->file . ' on line: ' . $this->line . '].');
 }