static function init($servers = [])
 {
     if (!isset(static::$obj)) {
         static::$obj = new Static($servers);
     }
     return static::$obj;
 }
Пример #2
0
 public static function all($columns = ['*'])
 {
     $columns = is_array($columns) ? $columns : func_get_arg();
     $instance = new static();
     $result = $instance->con->queryResult("SELECT " . implode(',', $columns) . " FROM " . $instance->table);
     return $instance->obj($result);
 }
Пример #3
0
 static function set($name, $value)
 {
     if (extension_loaded('memcache')) {
         if (!static::$obj) {
             static::$obj = new Memcache();
             static::$obj->connect('127.0.0.1', 11211) or die("memcache is enable but not work, 127.0.0.1 11211");
             static::$type = 'memcache';
         }
         if ($value) {
             static::$obj->set($name, $value, false, 0);
         } else {
             return static::$obj->get($name);
         }
     } elseif (extension_loaded('apc')) {
         static::$type = 'apc';
         if ($value) {
             apc_add($name, $value);
         } else {
             return apc_fetch($name);
         }
     } else {
         static::$file = $file = __DIR__ . '/../runtime/' . md5($name) . '.php';
         if (!$value) {
             if (!file_exists($file)) {
                 return false;
             }
             return unserialize(include $file);
         }
         $str = "<?php return '";
         $str .= serialize($value);
         $str .= "';";
         file_put_contents($file, $str);
     }
 }
Пример #4
0
 private static function instance()
 {
     if (static::$obj === NULL) {
         $klass = \Sauce\Config::get('logger');
         if (!$klass instanceof \Psr\Log\LoggerInterface) {
             $klass = new \Sauce\LoggerAware();
         } elseif (is_string($klass)) {
             $klass = new $klass();
         }
         static::$obj = $klass;
     }
     return static::$obj;
 }
Пример #5
0
 /** 
  *	静态方法实现
  */
 public static function __callStatic($name, $arguments)
 {
     static::$obj = new lib();
     return call_user_func_array(array(static::$obj, $name), $arguments);
 }
Пример #6
0
 /**
  * 查看目录下的所有目录及文件
  * 
  *
  * @example  File::find($dir , $find="*" )   
  * @param string $dir 目录 
  * @param string $find   所有文件,默认为*
  * @return void
  */
 static function find($dir, $find = '*')
 {
     $ar = static::__find($dir, $find);
     static::$obj = [];
     return $ar;
 }
Пример #7
0
 /**
  * 初始化 
  */
 static function init()
 {
     if (!isset(static::$obj)) {
         static::$obj = new Static();
     }
     return static::$obj;
 }
Пример #8
0
 public static function this($executor = null, $processor = null)
 {
     static::$obj = static::$obj ? static::$obj : static::create($executor, $processor);
     return static::$obj;
 }