/**
 +----------------------------------------------------------
 * 显示运行时间、数据库操作、缓存次数、内存使用信息
 +----------------------------------------------------------
 * @access private
 +----------------------------------------------------------
 * @return string
 +----------------------------------------------------------
 */
 private function showTime()
 {
     // 显示运行时间
     G('beginTime', $GLOBALS['_beginTime']);
     G('viewEndTime');
     $showTime = 'Process: ' . G('beginTime', 'viewEndTime') . 's ';
     // 显示详细运行时间
     $showTime .= '( Load:' . G('beginTime', 'loadTime') . 's Init:' . G('loadTime', 'initTime') . 's Exec:' . G('initTime', 'viewStartTime') . 's Template:' . G('viewStartTime', 'viewEndTime') . 's )';
     // 显示数据库操作次数
     if (class_exists('Db', false)) {
         $showTime .= ' | DB :' . N('db_query') . ' queries ' . N('db_write') . ' writes ';
     }
     // 显示缓存读写次数
     if (class_exists('Cache', false)) {
         $showTime .= ' | Cache :' . N('cache_read') . ' gets ' . N('cache_write') . ' writes ';
     }
     // 显示内存开销
     if (MEMORY_LIMIT_ON) {
         $showTime .= ' | UseMem:' . number_format((memory_get_usage() - $GLOBALS['_startUseMems']) / 1024) . ' kb';
     }
     // 显示文件加载数
     $showTime .= ' | LoadFile:' . count(get_included_files());
     // 显示函数调用次数 自定义函数,内置函数
     $fun = get_defined_functions();
     $showTime .= ' | CallFun:' . count($fun['user']) . ',' . count($fun['internal']);
     return $showTime;
 }
Example #2
0
 /**
  * 写入缓存
  * @access public
  * @param string $name 缓存变量名
  * @param mixed $value  存储数据
  * @param integer $expire  有效时间(秒)
  * @return boolen
  */
 public function set($name, $value, $expire = null)
 {
     N('cache_write', 1);
     $expire = !empty($expireTime) ? $expireTime : C('DATA_CACHE_TIME');
     $name = $this->options['prefix'] . sqlite_escape_string($name);
     $value = sqlite_escape_string(serialize($value));
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     $expire = $expire == 0 ? 0 : time() + $expire;
     //缓存有效期为0表示永久缓存
     if (C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
         //数据压缩
         $value = gzcompress($value, 3);
     }
     $sql = 'REPLACE INTO ' . $this->options['table'] . ' (var, value,expire) VALUES (\'' . $name . '\', \'' . $value . '\', \'' . $expire . '\')';
     if (sqlite_query($this->handler, $sql)) {
         if ($this->options['length'] > 0) {
             // 记录缓存队列
             $this->queue($name);
         }
         return true;
     }
     return false;
 }
 /**
  * 显示运行时间、数据库操作、缓存次数、内存使用信息
  * @access private
  * @return string
  */
 private function showTime()
 {
     // 显示运行时间
     G('beginTime', $GLOBALS['_beginTime']);
     G('viewEndTime');
     $showTime = 'Process: ' . G('beginTime', 'viewEndTime') . 's ';
     if (C('SHOW_ADV_TIME')) {
         // 显示详细运行时间
         $showTime .= '( Load:' . G('beginTime', 'loadTime') . 's Init:' . G('loadTime', 'initTime') . 's Exec:' . G('initTime', 'viewStartTime') . 's Template:' . G('viewStartTime', 'viewEndTime') . 's )';
     }
     if (C('SHOW_DB_TIMES') && class_exists('Db', false)) {
         // 显示数据库操作次数
         $showTime .= ' | DB :' . N('db_query') . ' queries ' . N('db_write') . ' writes ';
     }
     if (C('SHOW_CACHE_TIMES') && class_exists('Cache', false)) {
         // 显示缓存读写次数
         $showTime .= ' | Cache :' . N('cache_read') . ' gets ' . N('cache_write') . ' writes ';
     }
     if (MEMORY_LIMIT_ON && C('SHOW_USE_MEM')) {
         // 显示内存开销
         $showTime .= ' | UseMem:' . number_format((memory_get_usage() - $GLOBALS['_startUseMems']) / 1024) . ' kb';
     }
     if (C('SHOW_LOAD_FILE')) {
         $showTime .= ' | LoadFile:' . count(get_included_files());
     }
     if (C('SHOW_FUN_TIMES')) {
         $fun = get_defined_functions();
         $showTime .= ' | CallFun:' . count($fun['user']) . ',' . count($fun['internal']);
     }
     return $showTime;
 }
Example #4
0
 /**
 +----------------------------------------------------------
 * 写入缓存
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $name 缓存变量名
 * @param mixed $value  存储数据
 +----------------------------------------------------------
 * @return boolen
 +----------------------------------------------------------
 */
 public function set($name, $value, $expire = '')
 {
     N('cache_write', 1);
     if (empty($expire)) {
         $expire = $this->expire;
     }
     return xcache_set($name, $value, $expire);
 }
Example #5
0
 static function AK(AL $e, E $c) : E
 {
     $f = 'AJ';
     for ($g = 1, $h = N($c); $g < $e; $g++) {
         $f .= $c;
     }
     return $f;
 }
 /**
  * 显示页面Trace信息
  * @access private
  */
 private function showTrace()
 {
     // 系统默认显示信息
     $files = get_included_files();
     $info = array();
     foreach ($files as $key => $file) {
         $info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )';
     }
     $trace = array();
     $base = array('请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . __SELF__, '运行时间' => $this->showTime(), '内存开销' => MEMORY_LIMIT_ON ? number_format((memory_get_usage() - $GLOBALS['_startUseMems']) / 1024, 2) . ' kb' : '不支持', '查询信息' => N('db_query') . ' queries ' . N('db_write') . ' writes ', '文件加载' => count(get_included_files()), '缓存信息' => N('cache_read') . ' gets ' . N('cache_write') . ' writes ', '配置加载' => count(c()), '会话信息' => 'SESSION_ID=' . session_id());
     // 读取应用定义的Trace文件
     $traceFile = CONF_PATH . 'trace.php';
     if (is_file($traceFile)) {
         $base = array_merge($base, include $traceFile);
     }
     $debug = trace();
     $tabs = C('TRACE_PAGE_TABS', null, $this->tracePagTabs);
     foreach ($tabs as $name => $title) {
         switch (strtoupper($name)) {
             case 'BASE':
                 // 基本信息
                 $trace[$title] = $base;
                 break;
             case 'FILE':
                 // 文件信息
                 $trace[$title] = $info;
                 break;
             default:
                 // 调试信息
                 if (strpos($name, '|')) {
                     // 多组信息
                     $array = explode('|', $name);
                     $result = array();
                     foreach ($array as $name) {
                         $result += isset($debug[$name]) ? $debug[$name] : array();
                     }
                     $trace[$title] = $result;
                 } else {
                     $trace[$title] = isset($debug[$name]) ? $debug[$name] : '';
                 }
         }
     }
     foreach ($trace as $key => $val) {
         if (!is_array($val) && empty($val)) {
             $val = array();
         }
         if (is_array($val)) {
             $fire = array(array('', ''));
             foreach ($val as $k => $v) {
                 $fire[] = array($k, $v);
             }
             fb(array($key, $fire), FirePHP::TABLE);
         } else {
             fb($val, $key);
         }
     }
     unset($files, $info, $log, $base);
 }
Example #7
0
 /**
  * 执行语句
  * 
  * @access public
  * @param string $str
  *            sql指令
  * @param boolean $fetchSql
  *            不执行只是获取SQL
  * @return integer
  */
 public function execute($str, $fetchSql = false)
 {
     $this->initConnect(true);
     if (!$this->_linkID) {
         return false;
     }
     $this->queryStr = $str;
     if (!empty($this->bind)) {
         $that = $this;
         $this->queryStr = strtr($this->queryStr, array_map(function ($val) use($that) {
             return '\'' . $that->escapeString($val) . '\'';
         }, $this->bind));
     }
     if ($fetchSql) {
         return $this->queryStr;
     }
     $flag = false;
     if (preg_match("/^\\s*(INSERT\\s+INTO)\\s+(\\w+)\\s+/i", $str, $match)) {
         $this->table = C("DB_SEQUENCE_PREFIX") . str_ireplace(C("DB_PREFIX"), "", $match[2]);
         $flag = (bool) $this->query("SELECT * FROM user_sequences WHERE sequence_name='" . strtoupper($this->table) . "'");
     }
     // 释放前次的查询结果
     if (!empty($this->PDOStatement)) {
         $this->free();
     }
     $this->executeTimes++;
     N('db_write', 1);
     // 兼容代码
     // 记录开始执行时间
     $this->debug(true);
     $this->PDOStatement = $this->_linkID->prepare($str);
     if (false === $this->PDOStatement) {
         $this->error();
         return false;
     }
     foreach ($this->bind as $key => $val) {
         if (is_array($val)) {
             $this->PDOStatement->bindValue($key, $val[0], $val[1]);
         } else {
             $this->PDOStatement->bindValue($key, $val);
         }
     }
     $this->bind = array();
     $result = $this->PDOStatement->execute();
     $this->debug(false);
     if (false === $result) {
         $this->error();
         return false;
     } else {
         $this->numRows = $this->PDOStatement->rowCount();
         if ($flag || preg_match("/^\\s*(INSERT\\s+INTO|REPLACE\\s+INTO)\\s+/i", $str)) {
             $this->lastInsID = $this->_linkID->lastInsertId();
         }
         return $this->numRows;
     }
 }
Example #8
0
 /**
 +----------------------------------------------------------
 * 写入缓存
 *
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $name 缓存变量名
 * @param mixed $value  存储数据
 +----------------------------------------------------------
 * @return boolen
 +----------------------------------------------------------
 */
 function set($name, $value, $ttl = null)
 {
     N('cache_write', 1);
     if (isset($ttl) && is_int($ttl)) {
         $expire = $ttl;
     } else {
         $expire = $this->expire;
     }
     return apc_store($name, $value, $expire);
 }
 /**
 +----------------------------------------------------------
 * 写入缓存
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $name 缓存变量名
 * @param mixed $value  存储数据
 +----------------------------------------------------------
 * @return boolen
 +----------------------------------------------------------
 */
 public function set($name, $value, $ttl = null)
 {
     N('cache_write', 1);
     if (isset($ttl) && is_int($ttl)) {
         $expire = $ttl;
     } else {
         $expire = $this->expire;
     }
     eaccelerator_lock($name);
     return eaccelerator_put($name, $value, $expire);
 }
 /**
  * 写入缓存
  * @access public
  * @param string $name 缓存变量名
  * @param mixed $value  存储数据
  * @param integer $expire  有效时间(秒)
  * @return boolean
  */
 public function set($name, $value, $expire = null)
 {
     N('cache_write', 1);
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     $name = $this->options['prefix'] . $name;
     dump(json_encode(array('key' => $name, 'value' => $value, 'expire' => "" . $expire)));
     dump($this->options['root']);
     dump(file_post_contents($this->options['root'], json_encode(array('key' => $name, 'value' => $value, 'expire' => $expire))));
     return true;
 }
Example #11
0
 /**
 +----------------------------------------------------------
 * 写入缓存
 *
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $name 缓存变量名
 * @param mixed $value  存储数据
 * @param integer $expire  有效时间(秒)
 +----------------------------------------------------------
 * @return boolen
 +----------------------------------------------------------
 */
 public function set($name, $value, $expire = null)
 {
     N('cache_write', 1);
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     if ($result = apc_store($name, $value, $expire)) {
         if ($this->options['length'] > 0) {
             // 记录缓存队列
             $this->queue($name);
         }
     }
     return $result;
 }
Example #12
0
 /**
  * 显示页面Trace信息
  * @access private
  */
 private function showTrace()
 {
     // 系统默认显示信息
     $files = get_included_files();
     $info = [];
     foreach ($files as $key => $file) {
         $info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )';
     }
     $trace = [];
     Debug::remark('START', NOW_TIME);
     $base = ['请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['PHP_SELF'], '运行时间' => Debug::getUseTime('START', 'END', 6) . 's', '内存开销' => MEMORY_LIMIT_ON ? G('START', 'END', 'm') . 'b' : '不支持', '查询信息' => N('db_query') . ' queries ' . N('db_write') . ' writes ', '文件加载' => count($files), '缓存信息' => N('cache_read') . ' gets ' . N('cache_write') . ' writes ', '配置加载' => count(Config::get())];
     // 读取项目定义的Trace文件
     $traceFile = MODULE_PATH . 'trace.php';
     if (is_file($traceFile)) {
         $base = array_merge($base, include $traceFile);
     }
     $debug = Log::getLog();
     $tabs = Config::get('trace_page_tabs');
     foreach ($tabs as $name => $title) {
         switch (strtoupper($name)) {
             case 'BASE':
                 // 基本信息
                 $trace[$title] = $base;
                 break;
             case 'FILE':
                 // 文件信息
                 $trace[$title] = $info;
                 break;
             default:
                 // 调试信息
                 $name = strtoupper($name);
                 if (strpos($name, '|')) {
                     // 多组信息
                     $array = explode('|', $name);
                     $result = [];
                     foreach ($array as $name) {
                         $result += isset($debug[$name]) ? $debug[$name] : [];
                     }
                     $trace[$title] = $result;
                 } else {
                     $trace[$title] = isset($debug[$name]) ? $debug[$name] : '';
                 }
         }
     }
     unset($files, $info, $base, $debug);
     // 调用Trace页面模板
     ob_start();
     include Config::has('tmpl_trace_file') ? Config::get('tmpl_trace_file') : THINK_PATH . 'tpl/page_trace.tpl';
     return ob_get_clean();
 }
 /**
 +----------------------------------------------------------
 * 写入缓存
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $name 缓存变量名
 * @param mixed $value  存储数据
 * @param integer $expire  有效时间(秒)
 +----------------------------------------------------------
 * @return boolen
 +----------------------------------------------------------
 */
 public function set($name, $value, $expire = null)
 {
     N('cache_write', 1);
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     if (wincache_ucache_set($name, $value, $expire)) {
         if ($this->options['length'] > 0) {
             // 记录缓存队列
             $this->queue($name);
         }
         return true;
     }
     return false;
 }
Example #14
0
 /**
  * 写入缓存
  * @access public
  * @param string $name 缓存变量名
  * @param mixed $value  存储数据
  * @param integer $expire  有效时间(秒)
  * @return boolen
  */
 public function set($name, $value, $expire = null)
 {
     N('cache_write', 1);
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     $name = $this->options['prefix'] . $name;
     if ($this->handler->set($name, $value, 0, $expire)) {
         if ($this->options['length'] > 0) {
             // 记录缓存队列
             $this->queue($name);
         }
         return true;
     }
     return false;
 }
Example #15
0
 /**
  * 执行语句
  * 
  * @access public
  * @param string $str
  *            sql指令
  * @param boolean $fetchSql
  *            不执行只是获取SQL
  * @return mixed
  */
 public function execute($str, $fetchSql = false)
 {
     $this->initConnect(true);
     if (!$this->_linkID) {
         return false;
     }
     $this->queryStr = $str;
     if (!empty($this->bind)) {
         $that = $this;
         $this->queryStr = strtr($this->queryStr, array_map(function ($val) use($that) {
             return '\'' . $that->escapeString($val) . '\'';
         }, $this->bind));
     }
     if ($fetchSql) {
         return $this->queryStr;
     }
     // 释放前次的查询结果
     if (!empty($this->PDOStatement)) {
         $this->free();
     }
     $this->executeTimes++;
     N('db_write', 1);
     // 兼容代码
     // 记录开始执行时间
     $this->debug(true);
     $this->PDOStatement = $this->_linkID->prepare($str);
     if (false === $this->PDOStatement) {
         E($this->error());
     }
     foreach ($this->bind as $key => $val) {
         if (is_array($val)) {
             $this->PDOStatement->bindValue($key, $val[0], $val[1]);
         } else {
             $this->PDOStatement->bindValue($key, $val);
         }
     }
     $this->bind = array();
     $result = $this->PDOStatement->execute();
     $this->debug(false);
     if (false === $result) {
         $this->error();
         return false;
     } else {
         $this->numRows = $this->PDOStatement->rowCount();
         return $this->numRows;
     }
 }
Example #16
0
 /**
 +----------------------------------------------------------
 * 写入缓存
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $name 缓存变量名
 * @param mixed $value  存储数据
 * @param integer $expire  有效时间(秒)
 +----------------------------------------------------------
 * @return boolen
 +----------------------------------------------------------
 */
 public function set($name, $value, $expire = null)
 {
     N('cache_write', 1);
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     //Editor:anqiu xiao 2012-03-23 10:03
     $flag = C('DATA_CACHE_COMPRESS') ? MEMCACHE_COMPRESSED : 0;
     if ($this->handler->set($name, $value, $flag, $expire)) {
         if ($this->options['length'] > 0) {
             // 记录缓存队列
             $this->queue($name);
         }
         return true;
     }
     return false;
 }
Example #17
0
 /**
  * 写入缓存
  * @access public
  * @param string  $name   缓存变量名
  * @param mixed   $value  存储数据
  * @param integer $expire 有效时间(秒)
  * @return boolen
  */
 public function set($name, $value, $expire = NULL)
 {
     N('cache_write', 1);
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     $name = $this->options['prefix'] . $name;
     eaccelerator_lock($name);
     if (eaccelerator_put($name, $value, $expire)) {
         if ($this->options['length'] > 0) {
             // 记录缓存队列
             $this->queue($name);
         }
         return true;
     }
     return false;
 }
Example #18
0
 public function index()
 {
     $ActivityBonus = M('activity_bonus');
     //        $oldNumber = session('allNumber');
     //        $newNumber = array();
     //        $allNumber = empty($oldNumber) ? array() : $oldNumber;
     //        session('allNumber',NULL);dump('清除成功');die; //清除重新生成
     for ($i = 1; $i <= 20000; $i++) {
         $number = $this->getNumber();
         //刮刮卡号码不能重复
         //            if(in_array($number, $allNumber) || in_array($number, $newNumber)){
         //                continue;
         //            }
         if ($i % 5 == 0 && $i > 0) {
             $bonus_key = mt_rand(0, 2);
             //随机键值
             $bonus_arr = array(5, 10, 15, 20);
             //红包种类
             $bonus_money = $bonus_arr[$bonus_key];
             //红包金额
         } else {
             $bonus_money = 0;
         }
         $data['number'] = $number;
         //            $data['bonus'] = $bonus_money;
         $newNumber[] = $number;
         $allData[] = $data;
     }
     //        if(empty($oldNumber)){
     //            $allNumber = $newNumber;
     //        }else{
     //            $allNumber = array_merge($newNumber,$oldNumber);
     //        }
     //
     //        session('allNumber',$allNumber);
     //
     //        dump(count($newNumber));
     //        dump(count($oldNumber));
     //        dump(count($allNumber));
     //        dump(count($allData));
     $result = $ActivityBonus->addAll($allData);
     N('newNumber', count($newNumber));
     N('db', 1);
     dump(N('newNumber'));
     dump(N('db'));
 }
Example #19
0
 /**
 +----------------------------------------------------------
 * 写入缓存
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $name 缓存变量名
 * @param mixed $value  存储数据
 * @param integer $expire  有效时间(秒)
 +----------------------------------------------------------
 * @return boolen
 +----------------------------------------------------------
 */
 public function set($name, $value, $expire = null)
 {
     N('cache_write', 1);
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     if (is_int($expire)) {
         $result = $this->handler->setex($name, $expire, $value);
     } else {
         $result = $this->handler->set($name, $value);
     }
     if ($result && $this->options['length'] > 0) {
         // 记录缓存队列
         $this->queue($name);
     }
     return $result;
 }
Example #20
0
 /**
  * 写入缓存
  * @access public
  * @param string $name 缓存变量名
  * @param mixed $value  存储数据
  * @param int $expire  有效时间 0为永久
  * @return boolen
  */
 public function set($name, $value, $expire = null)
 {
     N('cache_write', 1);
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     //[cluster] 设置S缓存
     $result = S_set($this->options['prefix'] . $name, $value, $expire);
     if ($result) {
         if ($this->options['length'] > 0) {
             // 记录缓存队列
             $this->queue($name);
         }
         return true;
     } else {
         return false;
     }
 }
 /**
 +----------------------------------------------------------
 * 写入缓存
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $name 缓存变量名
 * @param mixed $value  存储数据
 +----------------------------------------------------------
 * @return boolen
 +----------------------------------------------------------
 */
 public function set($name, $value)
 {
     N('cache_write', 1);
     $this->open();
     $value = serialize($value);
     $s = 'S' . pack('NN', strlen($name), strlen($value)) . $name . $value;
     fwrite($this->handler, $s);
     $ret = fgets($this->handler);
     $this->close();
     if ($ret === "OK\n") {
         if ($this->options['length'] > 0) {
             // 记录缓存队列
             $this->queue($name);
         }
         return true;
     }
     return false;
 }
Example #22
0
 /**
  * 写入缓存
  * @access public
  * @param string $name 缓存变量名
  * @param mixed $value  存储数据
  * @param integer $expire  有效时间(秒)
  * @return boolen
  */
 public function set($name, $value, $expire = null)
 {
     N('cache_write', 1);
     if (is_null($expire)) {
         $expire = time() + $this->options['expire'];
     } else {
         if ($expire > 0) {
             $expire = time() + $expire;
         }
     }
     if ($this->handler->set($name, $value, $expire)) {
         if ($this->options['length'] > 0) {
             // 记录缓存队列
             $this->queue($name);
         }
         return true;
     }
     return false;
 }
Example #23
0
 /**
  * 写入缓存
  * @access public
  * @param string $name 缓存变量名
  * @param mixed $value 存储数据
  * @param integer $expire 有效时间(秒)
  * @return boolen
  */
 public function set($name, $value, $expire = null)
 {
     N('cache_write', 1);
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     $name = $this->options['prefix'] . $name;
     //对数组/对象数据进行缓存处理,保证数据完整性
     $value = is_object($value) || is_array($value) ? json_encode($value) : $value;
     if (is_int($expire)) {
         $result = $this->handler->setex($name, $expire, $value);
     } else {
         $result = $this->handler->set($name, $value);
     }
     if ($result && $this->options['length'] > 0) {
         // 记录缓存队列
         $this->queue($name);
     }
     return $result;
 }
Example #24
0
 /**
  * (non-PHPdoc)
  *
  * @see Core_DB::execute()
  */
 public function execute($str)
 {
     $this->query_str = $this->parse_prefix($str);
     // 自动替换表前缀
     if (!is_resource($this->link)) {
         $this->connect();
     }
     N('db_write', 1);
     // 记录开始执行时间
     G('queryStartTime');
     $this->lastqueryid = sqlsrv_query($this->link, $str);
     $this->debug();
     if (false === $this->lastqueryid) {
         $this->error();
         return false;
     } else {
         $this->num_rows = sqlsrv_rows_affected($this->lastqueryid);
         $this->lastinsid = $this->mssql_insert_id();
         return $this->num_rows;
     }
 }
 /**
  * 
  *
  * @return MHTMLErrorDocumentView
  */
 public function __construct(MNumber $errorCode = null, MString $errorName = null, MString $errorMessage = null)
 {
     parent::__construct();
     if (!$errorCode) {
         $errorCode = N(0);
     }
     if (!$errorName) {
         $errorName = S("Unknown Error");
     }
     if (!$errorMessage) {
         $errorMessage = S("An Unknown Error Occoured!");
     }
     $this->errorCode = $errorCode;
     $this->errorName = $errorName;
     $this->errorMessage = $errorMessage;
     $this->errorCodeHeaderView = new MHTMLHeaderElementView();
     $this->addSubview($this->errorCodeHeaderView);
     $this->errorDescriptionParagraphView = new MHTMLParagraphView();
     $this->addSubview($this->errorDescriptionParagraphView);
     $this->updateView();
 }
Example #26
0
 /**
  * 写入缓存
  * @access public
  * @param string $name 缓存变量名
  * @param mixed $value  存储数据
  * @param integer $expire  有效时间(秒)
  * @return boolean
  */
 public function set($name, $value, $expire = null)
 {
     $data = serialize($value);
     $name = $this->options['prefix'] . addslashes($name);
     N('cache_write', 1);
     if (C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
         //数据压缩
         $data = gzcompress($data, 3);
     }
     if (C('DATA_CACHE_CHECK')) {
         //开启数据校验
         $crc = md5($data);
     } else {
         $crc = '';
     }
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     $expire = 0 == $expire ? 0 : time() + $expire;
     //缓存有效期为0表示永久缓存
     $result = $this->handler->query('select `cachekey` from `' . $this->options['table'] . '` where `cachekey`=\'' . $name . '\' limit 0,1');
     if (!empty($result)) {
         //更新记录
         $result = $this->handler->execute('UPDATE ' . $this->options['table'] . ' SET data=\'' . $data . '\' ,datacrc=\'' . $crc . '\',expire=' . $expire . ' WHERE `cachekey`=\'' . $name . '\'');
     } else {
         //新增记录
         $result = $this->handler->execute('INSERT INTO ' . $this->options['table'] . ' (`cachekey`,`data`,`datacrc`,`expire`) VALUES (\'' . $name . '\',\'' . $data . '\',\'' . $crc . '\',' . $expire . ')');
     }
     if ($result) {
         if ($this->options['length'] > 0) {
             // 记录缓存队列
             $this->queue($name);
         }
         return true;
     } else {
         return false;
     }
 }
Example #27
0
 /**
  * 写入缓存
  * 
  * @access public
  * @param string $name
  *            缓存变量名
  * @param mixed $value
  *            存储数据
  * @return boolean
  */
 public function set($name, $value)
 {
     N('cache_write', 1);
     $lh = $this->_lock();
     $val = $this->get();
     if (!is_array($val)) {
         $val = array();
     }
     if (C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
         // 数据压缩
         $value = gzcompress($value, 3);
     }
     $name = $this->options['prefix'] . $name;
     $val[$name] = $value;
     $val = serialize($val);
     if ($this->_write($val, $lh)) {
         if ($this->options['length'] > 0) {
             // 记录缓存队列
             $this->queue($name);
         }
         return true;
     }
     return false;
 }
Example #28
0
 /**
  * 执行语句
  * @access public
  * @param string $str  sql指令
  * @return integer|false
  */
 public function execute($str)
 {
     $this->initConnect(true);
     if (!$this->_linkID) {
         return false;
     }
     $this->queryStr = $str;
     //释放前次的查询结果
     if ($this->queryID) {
         $this->free();
     }
     N('db_write', 1);
     // 记录开始执行时间
     G('queryStartTime');
     $result = mysql_query($str, $this->_linkID);
     $this->debug();
     if (false === $result) {
         $this->error();
         return false;
     } else {
         $this->numRows = mysql_affected_rows($this->_linkID);
         $this->lastInsID = mysql_insert_id($this->_linkID);
         return $this->numRows;
     }
 }
 /**
 +----------------------------------------------------------
 * 执行语句 针对 INSERT, UPDATE 以及DELETE
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $str  sql指令
 +----------------------------------------------------------
 * @return integer
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 public function execute($str = '')
 {
     $this->connect();
     if (!$this->linkID) {
         return false;
     }
     if ($str != '') {
         $this->queryStr = $str;
     }
     //释放前次的查询结果
     if ($this->queryID) {
         $this->free();
     }
     N('db_write', 1);
     $result = mysql_query($this->queryStr, $this->linkID);
     $this->debug();
     if (false === $result) {
         if ($this->debug) {
             throw_exception($this->error());
         } else {
             return false;
         }
     } else {
         $this->numRows = mysql_affected_rows($this->linkID);
         $this->lastInsID = mysql_insert_id($this->linkID);
         return $this->numRows;
     }
 }
Example #30
0
 /**
 +----------------------------------------------------------
 * 显示运行时间、数据库操作、缓存次数、内存使用信息
 +----------------------------------------------------------
 * @access private
 +----------------------------------------------------------
 * @return string
 +----------------------------------------------------------
 */
 private function showTime()
 {
     // 显示运行时间
     G('viewStartTime');
     $showTime = 'Process: ' . G('beginTime', 'viewEndTime') . 's ';
     if (C('SHOW_ADV_TIME')) {
         // 显示详细运行时间
         $showTime .= '( Load:' . G('beginTime', 'loadTime') . 's Init:' . G('loadTime', 'initTime') . 's Exec:' . G('initTime', 'viewStartTime') . 's Template:' . G('viewStartTime', 'viewEndTime') . 's )';
     }
     if (C('SHOW_DB_TIMES') && class_exists('Db', false)) {
         // 显示数据库操作次数
         $showTime .= ' | DB :' . N('db_query') . ' queries ' . N('db_write') . ' writes ';
     }
     if (C('SHOW_CACHE_TIMES') && class_exists('Cache', false)) {
         // 显示缓存读写次数
         $showTime .= ' | Cache :' . N('cache_read') . ' gets ' . N('cache_write') . ' writes ';
     }
     if (MEMORY_LIMIT_ON && C('SHOW_USE_MEM')) {
         // 显示内存开销
         $startMem = array_sum(explode(' ', $GLOBALS['_startUseMems']));
         $endMem = array_sum(explode(' ', memory_get_usage()));
         $showTime .= ' | UseMem:' . number_format(($endMem - $startMem) / 1024) . ' kb';
     }
     return $showTime;
 }