Esempio n. 1
0
 /**
  * 记录日志
  * @param unknown $content 日志内容
  * @param boolean $if_sql 是否记录SQL
  */
 protected function log($content, $if_sql = true)
 {
     if ($if_sql) {
         $log = Uk86Log::uk86_read();
         if (!empty($log) && is_array($log)) {
             $content .= end($log);
         }
     }
     Uk86Log::uk86_record('queue\\' . $content, Uk86Log::RUN);
 }
Esempio n. 2
0
 /**
  * 从全文索引库搜索关键词
  * @param unknown $condition 条件
  * @param unknown $order 排序
  * @param number $pagesize 每页显示商品数
  * @return
  */
 public function getIndexerList($condition = array(), $order = array(), $pagesize = 24)
 {
     try {
         //全文搜索初始化
         $this->_createXS($pagesize, C('fullindexer.appname'));
         //设置搜索内容
         $this->_setQueryXS($condition, $order);
         //执行搜索
         $this->_searchXS();
         return array($this->_indexer_ids, $this->_indexer_count);
     } catch (XSException $e) {
         //             if (C('debug')) {
         //                 showMessage($e->getMessage(),'','html','error');
         //             } else {
         Uk86Log::uk86_record('search\\index' . $e->getMessage() . "\r\n" . $sql, Uk86Log::RUN);
         return false;
         //             }
     }
 }
Esempio n. 3
0
 /**
  * 显示页面Trace信息
  *
  * @return array
  */
 public static function showTrace()
 {
     $trace = array();
     //当前页面
     $trace[Uk86Language::uk86_get('nc_debug_current_page')] = $_SERVER['REQUEST_URI'] . '<br>';
     //请求时间
     $trace[Uk86Language::uk86_get('nc_debug_request_time')] = date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . '<br>';
     //系统运行时间
     $query_time = number_format(microtime(true) - StartTime, 3) . 's';
     $trace[Uk86Language::uk86_get('nc_debug_execution_time')] = $query_time . '<br>';
     //内存
     $trace[Uk86Language::uk86_get('nc_debug_memory_consumption')] = number_format(memory_get_usage() / 1024 / 1024, 2) . 'MB' . '<br>';
     //请求方法
     $trace[Uk86Language::uk86_get('nc_debug_request_method')] = $_SERVER['REQUEST_METHOD'] . '<br>';
     //通信协议
     $trace[Uk86Language::uk86_get('nc_debug_communication_protocol')] = $_SERVER['SERVER_PROTOCOL'] . '<br>';
     //用户代理
     $trace[Uk86Language::uk86_get('nc_debug_user_agent')] = $_SERVER['HTTP_USER_AGENT'] . '<br>';
     //会话ID
     $trace[Uk86Language::uk86_get('nc_debug_session_id')] = session_id() . '<br>';
     //执行日志
     $log = Uk86Log::uk86_read();
     $trace[Uk86Language::uk86_get('nc_debug_logging')] = count($log) ? count($log) . Uk86Language::uk86_get('nc_debug_logging_1') . '<br/>' . implode('<br/>', $log) : Uk86Language::uk86_get('nc_debug_logging_2');
     $trace[Uk86Language::uk86_get('nc_debug_logging')] = $trace[Uk86Language::uk86_get('nc_debug_logging')] . '<br>';
     //文件加载
     $files = get_included_files();
     $trace[Uk86Language::uk86_get('nc_debug_load_files')] = count($files) . str_replace("\n", '<br/>', substr(substr(print_r($files, true), 7), 0, -2)) . '<br>';
     return $trace;
 }
Esempio n. 4
0
 /**
  * 执行查询
  *
  * @param string $sql
  * @return mixed
  */
 public static function query($sql, $host = 'master')
 {
     self::connect($host);
     if (C('debug')) {
         uk86_addUpTime('queryStartTime');
     }
     $query = self::$link[$host]->query($sql);
     if (C('debug')) {
         uk86_addUpTime('queryEndTime');
     }
     if ($query === false) {
         $error = 'Db Error: ' . mysqli_error(self::$link[$host]);
         if (C('debug')) {
             uk86_throw_exception($error . '<br/>' . $sql);
         } else {
             Uk86Log::uk86_record($error . "\r\n" . $sql, Uk86Log::ERR);
             Uk86Log::uk86_record($sql, Uk86Log::SQL);
             return false;
         }
     } else {
         Uk86Log::uk86_record($sql . " [ RunTime:" . uk86_addUpTime('queryStartTime', 'queryEndTime', 6) . "s ]", Uk86Log::SQL);
         return $query;
     }
 }