Doctrine\DBAL\Connection::getHost PHP Method

getHost() public method

Gets the hostname of the currently connected database.
public getHost ( ) : string | null
return string | null
    public function getHost()
    {
        return isset($this->_params['host']) ? $this->_params['host'] : null;
    }

Usage Example

 public function getDsn()
 {
     $driver = $this->connection->getDriver()->getName();
     $user = $this->connection->getUsername();
     $pass = $this->connection->getPassword();
     $host = $this->connection->getHost();
     $db = $this->connection->getDatabase();
     return "{$driver}://{$user}:{$pass}@{$host}/{$db}";
 }
All Usage Examples Of Doctrine\DBAL\Connection::getHost