[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 query_cache.php

Zen Cart 源代码 query_cache.php




下载文件

文件名: query_cache.php
文件类型: PHP文件
文件大小: 1.42 KiB
MD5: 64fbd112fd1b2404c1a36fd76d9fb6fb

query_cache.php - 关闭高亮
  1. <?php
  2. /**
  3.  * Temporary cache for sql
  4.  *
  5.  * @package classes
  6.  * @copyright Copyright 2003-2014 Zen Cart Development Team
  7.  * @copyright Created by Data-Diggers.com http://www.data-diggers.com/
  8.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  9.  * @version GIT: $Id: Author: DrByte  Sun Mar 2 16:20:12 2014 -0500 Modified in v1.5.3 $
  10.  *
  11.  */
  12. /**
  13.  * QueryCache
  14.  *
  15.  */
  16.  class QueryCache {
  17.  
  18.     function QueryCache() {
  19.         $this->queries = array();
  20.     }
  21.  
  22.     // cache queries if and only if query is 'SELECT' statement
  23.     // returns:
  24.     //  TRUE - if and only if query has been stored in cache
  25.     //  FALSE - otherwise
  26.     function cache($query, $result) {
  27.         if ($this->isSelectStatement($query) === TRUE) $this->queries[$query] = $result;
  28.         else return(FALSE);
  29.         return(TRUE);
  30.     }
  31.  
  32.     function getFromCache($query) {
  33.         $ret = $this->queries[$query];
  34.         mysqli_data_seek($ret, 0);
  35.         return($ret);
  36.     }
  37.  
  38.     function inCache($query) {
  39.         return(isset($this->queries[$query]));
  40.     }
  41.  
  42.     function isSelectStatement($q) {
  43.         if(($q[0] == 's' || $q[0] == 'S')
  44.                 && ($q[1] == 'e' || $q[1] == 'E')
  45.                 && ($q[2] == 'l' || $q[2] == 'L'))
  46.             return(true);
  47.         return(false);
  48.     }
  49.  
  50.     function reset($query) {
  51.       if ('ALL' == $query) {
  52.         $this->queries = array();
  53.         return FALSE;
  54.       }
  55.       unset ($this->queries[$query]);
  56.     }
  57. }
  58.  
  59.