/** * 得到对象单例 * */ public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
/** * 记录SQL调试时间 * * @param string $sql 执行的SQL语句 * @param float $execTime 执行的时间 */ protected function _setDebugInfo($sql, $execTime) { // 总时间累加 $this->_totalTime += $execTime; // 是否设置了调试选项 $cfgObj = QP_Registry_Registry::getInstance(); if (!$cfgObj->keyExists('DB_DEBUG')) { $cfgObj->set('DB_DEBUG', array(array('sql' => $sql, 'execTime' => $execTime, 'totalTime' => $this->_totalTime))); } else { $data = $cfgObj->get('DB_DEBUG'); $data[] = array('sql' => $sql, 'execTime' => $execTime, 'totalTime' => $this->_totalTime); $cfgObj->set('DB_DEBUG', $data); } }
/** * 构造函数 * * @param string $appConfigFile APP的配置文件 */ public function __construct($appConfigFile) { // 载入APP配置 QP_Registry_Registry::getInstance()->set('APP_CFG', include $appConfigFile); }
</td> </tr> <tr> <td class="tgreen">匹配路由:</td><td class="tblue"><?php echo isset($debugInfo['router']) ? '<pre>' . htmlspecialchars(print_r($debugInfo['router'], true)) . '</pre>' : ' '; ?> </td> </tr> <tr class="tr_click" onclick="qp_debug_swap_show('qp_tr_sql')"> <td colspan="2">[SQL]</td> </tr> <tr style="display:none" id="qp_tr_sql"> <td colspan="2"> <?php $dbDebugInfo = (array) QP_Registry_Registry::getInstance()->get('DB_DEBUG'); foreach ($dbDebugInfo as $row) { ?> 时间:<span class="tred"><?php echo round($row['execTime'], 6); ?> </span> 累计:<span class="tred"><?php echo round($row['totalTime'], 6); ?> </span> SQL:<span class="tblue"><?php echo $row['sql']; ?> </span> <br/> <?php } ?>
/** * 得到 APP 的配置 * */ public static function getAppCfg() { return QP_Registry_Registry::getInstance()->get('APP_CFG'); }