示例#1
0
文件: Json.php 项目: zonquan/cmlphp
 /**
  * 输出数据
  *
  */
 public function display()
 {
     header('Content-Type: application/json;charset=' . Config::get('default_charset'));
     if ($GLOBALS['debug']) {
         $sqls = Debug::getSqls();
         if (isset($sqls[0])) {
             $this->args['sql'] = implode($sqls, ', ');
         }
     }
     Plugin::hook('cml.before_cml_stop');
     exit(json_encode($this->args, PHP_VERSION >= '5.4.0' ? JSON_UNESCAPED_UNICODE : 0));
 }
示例#2
0
 /**
  * 输出数据
  *
  */
 public function display()
 {
     header('Content-Type: application/json;charset=' . Config::get('default_charset'));
     if (Cml::$debug) {
         $sql = Debug::getSqls();
         if (Config::get('dump_use_php_console')) {
             $sql && \Cml\dumpUsePHPConsole($sql, 'sql');
             \Cml\dumpUsePHPConsole(Debug::getTipInfo(), 'tipInfo');
             \Cml\dumpUsePHPConsole(Debug::getIncludeFiles(), 'includeFile');
         } else {
             if (isset($sql[0])) {
                 $this->args['sql'] = implode($sql, ', ');
             }
         }
     } else {
         $deBugLogData = \Cml\dump('', 1);
         if (!empty($deBugLogData)) {
             Config::get('dump_use_php_console') ? \Cml\dumpUsePHPConsole($deBugLogData, 'debug') : ($this->args['cml_debug_info'] = $deBugLogData);
         }
     }
     exit(json_encode($this->args, JSON_UNESCAPED_UNICODE));
 }
示例#3
0
文件: Pdo.php 项目: linhecheng/cmlphp
 /**
  * Debug模式记录查询语句显示到控制台
  *
  * @param int $type
  * @param int $other $other type = SQL_TYPE_SLOW时带上执行时间
  */
 private function debugLogSql($type = Debug::SQL_TYPE_NORMAL, $other = 0)
 {
     Debug::addSqlInfo($this->buildDebugSql(), $type, $other);
 }
示例#4
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);
     }
 }
示例#5
0
文件: Cml.php 项目: linhecheng/cmlphp
 /**
  * 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;
 }
示例#6
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;
 }
示例#7
0
 /**
  * 记录不支持的方法
  *
  * @param int $method
  */
 private function logNotSupportMethod($method)
 {
     Cml::$debug && Debug::addTipInfo('MongoDb NotSupport [' . $method . '] Method', Debug::TIP_INFO_TYPE_INFO, 'red');
 }
示例#8
0
 /**
  * Debug模式记录查询语句显示到控制台
  *
  * @param string $type 查询的类型
  * @param string $tableName 查询的Collection
  * @param array $condition 条件
  * @param array $options 额外参数
  */
 private function debugLogSql($type = 'Query', $tableName, $condition = [], $options = [])
 {
     if (Cml::$debug) {
         Debug::addSqlInfo(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)));
     }
 }
示例#9
0
文件: Cml.php 项目: dlpc/cmlphp
 /**
  * 自动加载类库
  * 要注意的是 使用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中显示包含的类
 }
示例#10
0
文件: Cml.php 项目: dlpc/cmlphp
 /**
  * 程序中并输出调试信息
  *
  */
 public static function cmlStop()
 {
     Plugin::hook('cml.before_cml_stop');
     //输出Debug模式的信息
     if ($GLOBALS['debug']) {
         header('Content-Type:text/html; charset=' . Config::get('default_charset'));
         Debug::stop();
     } else {
         $deBugLogData = dump('', 1);
         if (!empty($deBugLogData)) {
             require CML_PATH . DIRECTORY_SEPARATOR . 'Cml' . DIRECTORY_SEPARATOR . 'ConsoleLog.php';
         }
         CML_OB_START && ob_end_flush();
         exit;
     }
 }
示例#11
0
 /**
  * 输出调试消息
  *
  * @return void
  */
 public function stopAndShowDebugInfo()
 {
     if (Request::isAjax()) {
         if (Config::get('dump_use_php_console')) {
             self::$sql && \Cml\dumpUsePHPConsole(self::$sql, 'sql');
             \Cml\dumpUsePHPConsole(self::$tipInfo, 'tipInfo');
             \Cml\dumpUsePHPConsole(self::$includeFile, 'includeFile');
         } else {
             $deBugLogData = ['tipInfo' => self::$tipInfo];
             self::$sql && ($deBugLogData['sql'] = self::$sql);
             if (!empty($deBugLogData)) {
                 Cml::requireFile(CML_CORE_PATH . DIRECTORY_SEPARATOR . 'ConsoleLog.php', ['deBugLogData' => $deBugLogData]);
             }
         }
     } else {
         View::getEngine('html')->assign('includeLib', Debug::getIncludeLib())->assign('includeFile', Debug::getIncludeFiles())->assign('tipInfo', Debug::getTipInfo())->assign('sqls', Debug::getSqls())->assign('usetime', Debug::getUseTime())->assign('usememory', Debug::getUseMemory());
         Cml::showSystemTemplate(Config::get('debug_page'));
     }
 }
示例#12
0
文件: Pdo.php 项目: zonquan/cmlphp
 /**
  * 预处理语句
  *
  * @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;
 }
示例#13
0
 /**
  * 程序中并输出调试信息
  *
  */
 public static function cmlStop()
 {
     //输出Debug模式的信息
     if ($GLOBALS['debug']) {
         header('Content-Type:text/html; charset=' . Config::get('default_charset'));
         Debug::stop();
     } else {
         $deBugLogData = dump('', 1);
         if (!empty($deBugLogData)) {
             Config::get('dump_use_php_console') ? \Cml\dumpUsePHPConsole($deBugLogData) : (require CML_PATH . DIRECTORY_SEPARATOR . 'Cml' . DIRECTORY_SEPARATOR . 'ConsoleLog.php');
         }
         CML_OB_START && ob_end_flush();
         exit;
     }
 }