Elgg\Database::getConnection PHP Method

getConnection() protected method

Gets (if required, also creates) a DB connection.
protected getConnection ( string $type ) : Doctrine\DBAL\Connection
$type string The type of link we want: "read", "write" or "readwrite".
return Doctrine\DBAL\Connection
    protected function getConnection($type)
    {
        if (isset($this->connections[$type])) {
            return $this->connections[$type];
        } else {
            if (isset($this->connections['readwrite'])) {
                return $this->connections['readwrite'];
            } else {
                $this->setupConnections();
                return $this->getConnection($type);
            }
        }
    }