loadDevelop(); } public static function db($table, $app = '', $store = 'default', $partition = false, $path = 'table') { if (!$app) { $app = DEVER_APP_NAME; } $index = $app . $path . $table; if (empty(self::$data[$index])) { self::$data[$index] = new Dever\Model($table, $app, $store, $partition, $path); } return self::$data[$index]; } public static function config() { return Dever\Config::get(...func_get_args()); } public static function apply() { return Library::get()->apply(...func_get_args()); } public static function success() { return Dever\Output::success(...func_get_args()); } public static function error() { return Dever\Output::error(...func_get_args()); } public static function out() { return Dever\Output::out(...func_get_args()); } public static function input() { return Dever\Route::input(...func_get_args()); } public static function url() { return Dever\Route::url(...func_get_args()); } public static function project() { return Dever\Project::load(...func_get_args()); } public static function log() { return Dever\Log::add(...func_get_args()); } public static function debug() { return Dever\Debug::add(...func_get_args()); } public static function session() { return Dever\Session::oper(...func_get_args()); } public static function view() { return Dever\View::show(...func_get_args()); } public static function path() { return Dever\Path::get(...func_get_args()); } public static function curl() { $curl = new Dever\Helper\Curl(); return $curl->log(true)->load(...func_get_args()); } public static function cache($key, $value = false) { if (isset(self::config('setting')['redis'])) { if ($value) { if ($value == 'delete') { return \Dever\Helper\Redis::delete($key); } return \Dever\Helper\Redis::set($key, self::json_encode($value)); } else { return self::json_decode(\Dever\Helper\Redis::get($key)); } } return false; } public static function shell($value) { return Dever::check(Dever\Route::input('shell'), $value); } public static function store($store = 'default', $partition = false) { $setting = Dever\Config::get('setting')['database'][$store]; $class = 'Dever\\Store\\' . $setting['type']; return $class::getInstance($store, $setting, $partition); } public static function check($var, $find) { if (is_array($var)) { $var = implode(',', $var); } $var = ',' . $var . ','; $find = ',' . $find . ','; return strpos($var, $find) !== false; } public static function json_encode($value) { $value = json_encode($value, JSON_UNESCAPED_UNICODE); return $value; } public static function json_decode($value) { return json_decode($value, true); } public static function array_order($array, $key, $sort) { $reorder = array_column($array, $key); array_multisort($reorder, $sort, $array); return $array; } public static function number($number, $num = 2, $type = 1) { if ($type == 2) { return number_format($number, $num); } if ($type == 3) { return round($number, $num); } return sprintf("%.".$num."f", $number); } public static function uuid() { mt_srand((double)microtime() * 10000); $charid = strtoupper(self::id()); $hyphen = chr(45); return chr(123).substr($charid, 0, 8).$hyphen.substr($charid, 8, 4).$hyphen.substr($charid,12, 4).$hyphen.substr($charid,16, 4).$hyphen.substr($charid,20,12).chr(125); } public static function id() { $charid = strtoupper(md5(uniqid(mt_rand(), true))); return substr($charid, 0, 8) . substr($charid, 8, 4) . substr($charid, 12, 4) . substr($charid, 16, 4) . substr($charid, 20, 12); } }