src/DatabaseManager.php
public function database(string $database = null): DatabaseInterface
    {
        if (empty($database)) {
            $database = $this->config->getDefaultDatabase();
        }

        //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 DBALException(
                "Unable to create Database, no presets for '{$database}' found"
            );
        }

        return $this->databases[$database] = $this->makeDatabase(
            $this->config->getDatabase($database)
        );
    }
public function database(string $database = null): DatabaseInterface
    {
        if (empty($database)) {
            $database = $this->config->getDefaultDatabase();
        }

        //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 DBALException(
                "Unable to create Database, no presets for '{$database}' found"
            );
        }

        return $this->databases[$database] = $this->makeDatabase(
            $this->config->getDatabase($database)
        );
    }
public function database ( string $ database = null ) : DatabaseInterface { if ( empty ( $ database ) ) { $ database = $ this -> config -> getDefaultDatabase ( ) ; } //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 DBALException ( "Unable to create Database, no presets for '{$database}' found" ) ; } return $ this -> databases [ $ database ] = $ this -> makeDatabase ( $ this -> config -> getDatabase ( $ database ) ) ; }
Get Database associated with a given database alias or automatically created one.

@param string|null $database
@return Database|DatabaseInterface

@throws DBALException
Get Database associated with a given database alias or automatically created one .