Esempio n. 1
0
 /**
  * 缓存表字段信息,并返回
  * @staticvar array $info  字段信息数组
  * @param type $tableName  不含前缀的表名称
  * @return array
  */
 public static function getTableFieldsInfo($tableName, $db)
 {
     if (!empty(self::$table_cache[$tableName])) {
         return self::$table_cache[$tableName];
     }
     if (!file_exists($cache_file = Fn::systemInfo('table_cache_folder') . DIRECTORY_SEPARATOR . $tableName . '.php')) {
         $info = array();
         $result = $db->query('SHOW FULL COLUMNS FROM ' . $db->dbprefix . $tableName)->result_array();
         if ($result) {
             foreach ($result as $val) {
                 $info[$val['Field']] = array('name' => $val['Field'], 'type' => $val['Type'], 'comment' => $val['Comment'] ? $val['Comment'] : $val['Field'], 'notnull' => $val['Null'] == 'NO' ? 1 : 0, 'default' => $val['Default'], 'primary' => strtolower($val['Key']) == 'pri', 'autoinc' => strtolower($val['Extra']) == 'auto_increment');
             }
         }
         $content = 'return ' . var_export($info, true) . ";\n";
         $content = '<?' . 'php' . "\n" . $content;
         file_put_contents($cache_file, $content);
         $ret_info[$tableName] = $info;
     } else {
         $ret_info[$tableName] = (include $cache_file);
     }
     return $ret_info[$tableName];
 }
Esempio n. 2
0
 /**
  * 设置一个cookie,该方法会在key前面加上系统配置里面的$system['cookie_key_prefix']前缀
  * 如果不想加前缀,可以使用方法:$this->setCookieRaw()
  */
 public static function setCookie($key, $value, $life = null, $path = '/', $domian = null, $http_only = false)
 {
     $key = Fn::systemInfo('cookie_key_prefix') . $key;
     return self::setCookieRaw($key, $value, $life, $path, $domian, $http_only);
 }
Esempio n. 3
0
 /**
  * 获取一个cookie
  * 提醒:
  * 该方法会在key前面加上系统配置里面的$system['cookie_key_prefix']
  * 如果想不加前缀,获取原始key的cookie,可以使用方法:$this->input->cookie_raw();
  * @param string $key      cookie键
  * @param type $default    默认值
  * @param type $xss_clean  xss过滤
  * @return type
  */
 public static function cookie($key = null, $default = null, $xss_clean = false)
 {
     $key = Fn::systemInfo('cookie_key_prefix') . $key;
     return self::cookieRaw($key, $default, $xss_clean);
 }