$database) { $app->set($key, $this->_settings($database)); } } /** * @param $name * @return Connection * @throws Exception */ public function get($name): Connection { return Kiri::app()->get($name); } /** * @param $database * @return array */ private function _settings($database): array { $clientPool = $database['pool'] ?? ['min' => 1, 'max' => 5, 'tick' => 60]; return [ 'id' => $database['id'], 'cds' => $database['cds'], 'class' => Connection::class, 'username' => $database['username'], 'password' => $database['password'], 'tablePrefix' => $database['tablePrefix'], 'database' => $database['database'], 'connect_timeout' => $database['connect_timeout'] ?? 30, 'read_timeout' => $database['read_timeout'] ?? 10, 'pool' => $clientPool, 'attributes' => $database['attributes'] ?? [], 'charset' => $database['charset'] ?? 'utf8mb4', 'slaveConfig' => $database['slaveConfig'] ]; } }