public static function connect() { if (!is_object(self::$_kvdb)) { self::$_kvdb = new KVClient(); // 初始化KVClient对象 $ret = self::$_kvdb->init(); if ($ret === false) { exit('初始化对象失败!!'); } } return self::$_kvdb; }
public function __construct() { $this->kvdbObj = Kvdb::connect(); }
} else { if ($count == 0 && !empty($zero)) { return $zero; } else { if ($count == 0 && empty($zero)) { return $one; } else { return $many; } } } }); $params = Bootstrap::$bag['config']->getDatabase(); $dsn = Config::get('database.adapter', 'mysql') . ":dbname=" . Config::get('database.dbname', SITE_NAME) . ";host=" . Config::get('database.host', 'localhost'); $params->setDsn($dsn); Entitydb::$driver = Kvdb::instance($params); context('nosql')->orm(function ($entity) { $args = func_get_args(); $ns = isset($args[1]) ? $args[1] : 'core'; $ns = !is_string($ns) ? 'core' : $ns; if (is_string($entity) && is_string($entity)) { static $i = array(); $db = isAke($i, $entity, null); if (is_null($db)) { $i[$entity] = $db = new Redistorage($entity, $ns); } return $db; } }); $core->route(function (Container $route) { $routes = container()->getRoutes();