/** * {@inheritdoc} * * @return Database */ public function database($database = null) { if (empty($database)) { $database = $this->config->defaultDatabase(); } //Spiral support ability to link multiple virtual databases together using aliases $database = $this->config->resolveAlias($database); if (isset($this->databases[$database])) { return $this->databases[$database]; } if (!$this->config->hasDatabase($database)) { throw new DatabaseException("Unable to create database, no presets for '{$database}' found."); } //No need to benchmark here, due connection will happen later $this->databases[$database] = $this->factory->make(Database::class, ['name' => $database, 'driver' => $this->driver($this->config->databaseConnection($database)), 'prefix' => $this->config->databasePrefix($database)]); return $this->databases[$database]; }