addTipInfo() публичный статический Метод

添加调试信息
public static addTipInfo ( string $msg, integer $type = self::TIP_INFO_TYPE_INFO ) : void
$msg string 调试消息字符串
$type integer 消息的类型
Результат void
Пример #1
0
 /**
  * require 引入文件
  *
  * @param string $file 要引入的文件
  * @param array $args 要释放的变量
  *
  * @return mixed
  */
 public static function requireFile($file, $args = [])
 {
     empty($args) || extract($args, EXTR_PREFIX_SAME, "xxx");
     Cml::$debug && Debug::addTipInfo($file, Debug::TIP_INFO_TYPE_INCLUDE_FILE);
     return require $file;
 }
Пример #2
0
 /**
  * Debug模式记录查询语句显示到控制台
  *
  * @param string $type 查询的类型
  * @param string $tableName 查询的Collection
  * @param array $condition 条件
  * @param array $options 额外参数
  */
 private function debugLogSql($type = 'Query', $tableName, $condition = array(), $options = array())
 {
     if ($GLOBALS['debug']) {
         Debug::addTipInfo(sprintf("[MongoDB {$type}] Collection: %s, Condition: %s, Other: %s", $this->getDbName() . ".{$tableName}", json_encode($condition, PHP_VERSION >= '5.4.0' ? JSON_UNESCAPED_UNICODE : 0), json_encode($options, PHP_VERSION >= '5.4.0' ? JSON_UNESCAPED_UNICODE : 0)), 2);
     }
 }
Пример #3
0
 /**
  * 预处理语句
  *
  * @param string $sql 要预处理的sql语句
  * @param \PDO $link
  * @param bool $resetParams
  *
  * @return \PDOStatement
  */
 public function prepare($sql, $link = null, $resetParams = true)
 {
     $resetParams && $this->reset();
     is_null($link) && ($link = $this->wlink);
     if ($GLOBALS['debug']) {
         $bindParams = $this->bindParams;
         foreach ($bindParams as $key => $val) {
             $bindParams[$key] = str_replace('\\\\', '\\', addslashes($val));
         }
         Debug::addTipInfo(vsprintf(str_replace('%s', "'%s'", $sql), $bindParams), 2);
     }
     $sqlParams = array();
     foreach ($this->bindParams as $key => $val) {
         $sqlParams[] = ':param' . $key;
     }
     $tipSql = $sql;
     $sql = vsprintf($sql, $sqlParams);
     $stmt = $link->prepare($sql);
     //pdo默认情况prepare出错不抛出异常只返回Pdo::errorInfo
     if ($stmt === false) {
         $error = $link->errorInfo();
         $bindParams = $this->bindParams;
         foreach ($bindParams as $key => $val) {
             $bindParams[$key] = str_replace('\\\\', '\\', addslashes($val));
         }
         \Cml\throwException('Pdo Prepare Sql error! ,【Sql : ' . vsprintf(str_replace('%s', "'%s'", $tipSql), $bindParams) . '】,【Code:' . $link->errorCode() . '】, 【ErrorInfo!:' . $error[2] . '】 <br />');
     } else {
         $this->currentSql = $tipSql;
         foreach ($this->bindParams as $key => $val) {
             is_int($val) ? $stmt->bindValue(':param' . $key, $val, \PDO::PARAM_INT) : $stmt->bindValue(':param' . $key, $val, \PDO::PARAM_STR);
         }
         return $stmt;
     }
     return false;
 }
Пример #4
0
 /**
  * 记录不支持的方法
  *
  * @param int $method
  */
 private function logNotSupportMethod($method)
 {
     Cml::$debug && Debug::addTipInfo('MongoDb NotSupport [' . $method . '] Method', Debug::TIP_INFO_TYPE_INFO, 'red');
 }
Пример #5
0
 /**
  * 自动加载类库
  * 要注意的是 使用autoload的时候  不能手动抛出异常
  * 因为在自动加载静态类时手动抛出异常会导致自定义的致命错误捕获机制和自定义异常处理机制失效
  * 而 new Class 时自动加载不存在文件时,手动抛出的异常可以正常捕获
  * 这边即使文件不存在时没有抛出自定义异常也没关系,因为自定义的致命错误捕获机制会捕获到错误
  *
  * @params string $className
  */
 public static function autoloadComposerAdditional($className)
 {
     $GLOBALS['debug'] && \Cml\Debug::addTipInfo(\Cml\Lang::get('_CML_DEBUG_ADD_CLASS_TIP_', $className), 1);
     //在debug中显示包含的类
 }
Пример #6
0
 /**
  * 启动框架
  *
  */
 public static function runApp()
 {
     //系统初始化
     self::init();
     //控制器所在路径
     $actionController = CML_APP_CONTROLLER_PATH . Route::$urlParams['controller'] . 'Controller.php';
     $GLOBALS['debug'] && Debug::addTipInfo(Lang::get('_CML_ACTION_CONTROLLER_', $actionController));
     Plugin::hook('cml.before_run_controller');
     if (is_file($actionController)) {
         $className = Route::$urlParams['controller'] . 'Controller';
         $className = (CML_IS_MULTI_MODULES ? '' : '\\Controller') . Route::$urlParams['path'] . (CML_IS_MULTI_MODULES ? 'Controller' . DIRECTORY_SEPARATOR : '') . "{$className}";
         $className = str_replace('/', '\\', $className);
         $controller = new $className();
         call_user_func(array($controller, "runAppController"));
         //运行
     } else {
         self::montFor404Page();
         if ($GLOBALS['debug']) {
             throwException(Lang::get('_CONTROLLER_NOT_FOUND_', CML_APP_CONTROLLER_PATH, Route::$urlParams['controller'], str_replace('/', '\\', Route::$urlParams['path']) . Route::$urlParams['controller']));
         } else {
             Response::show404Page();
         }
     }
     //输出Debug模式的信息
     self::cmlStop();
 }
Пример #7
0
 /**
  * 预处理语句
  *
  * @param string $sql
  * @param \PDO $link
  * @param bool $resetParams
  *
  * @return \PDOStatement
  */
 public function prepare($sql, $link = null, $resetParams = true)
 {
     $resetParams && $this->reset();
     is_null($link) && ($link = $this->wlink);
     if ($GLOBALS['debug']) {
         $bindParams = $this->bindParams;
         foreach ($bindParams as $key => $val) {
             $bindParams[$key] = str_replace('\\\\', '\\', addslashes($val));
         }
         Debug::addTipInfo(vsprintf(str_replace('?', "'%s'", $sql), $bindParams), 2);
     }
     try {
         return $link->prepare($sql);
     } catch (\PDOException $e) {
         \Cml\throwException('Pdo Prepare Sql error! Code:' . $e->getCode() . ',ErrorInfo!:' . $e->getMessage() . '<br />');
     }
     return false;
 }