Return the stored database connection.

@return mixed
968636
public function getConnection()
    {
        if (is_null($this->_connection)) {
            $this->setConnection(
                Agl::app()->getConfig('main/db/host'),
                Agl::app()->getConfig('main/db/name'),
                Agl::app()->getConfig('main/db/user'),
                Agl::app()->getConfig('main/db/password')
            );
        }

        return $this->_connection;
    }
469070
public function getDb(): ?ConnectionInterface
    {
        if (!$this->hasDb()) {
            $this->setDb($this->getDefaultDb());
        }
        return $this->db;
    }
99741
public function getConn()
    {
        if ($this->conn === null) {
            $this->conn = Connection::connect($this->req->getUrlParam('conn'), $this);
            if ($this->conn === false) {
                $this->res->error = Connection::getLastError();
                $this->finish();
            } else {
                if ($this->conn !== null) {
                    $this->conn->addWriteData($this->getRequestBuf());
                }
            }
        }
        return $this->conn;
    }
1137206
public function getConnectionString(){
        $connection_string = array();

        $type = $this->getType();
        array_push($connection_string, $type);

        if($type == self::SQLite){
        	$filename = 'db.sqlite';
        	if(isset($this->properties['filename']))
        		$filename = $this->properties['filename'];
        	array_push($connection_string, ":$filename");
        }
        else {
	        array_push($connection_string, ':host=');
	        array_push($connection_string,
	            (isset($this->properties['host']))?
	            $this->properties['host']:'localhost'
	        );
	        array_push($connection_string, ';dbname=');
	        array_push($connection_string,
	            (isset($this->properties['name']))?
	            $this->properties['name']:null
	        );
        }
        
        array_push($connection_string, ';charset=');
        array_push($connection_string, $this->getCharset());
        return implode($connection_string);
    }
1351359
public function getRedis(): ?Connection
    {
        if (!$this->hasRedis()) {
            $this->setRedis($this->getDefaultRedis());
        }
        return $this->redis;
    }
1071282
public function getDatabase()
    {
        $database = [];

        if (class_exists('O2System\Framework', false)) {
            if (services()->has('database')) {
                $connections = database()->getIterator();

                foreach ($connections as $offset => $connection) {
                    $database[ $offset ] = $connection->getQueries();
                }
            }
        }

        return $database;
    }
74870
public static function db()
    {
        self::$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        return self::$conn;
    }
127712
public function getConnection()
    {
        if ($this->connection === null) {
            $this->connection = ConnectionManager::get('auditlog_elastic');
        }

        return $this->connection;
    }
1337263
public function getConnection()
    {
        // Initiate connection if not exist
        if ($this->connection === null) {
            $this->connection = DriverManager::getConnection($this->dsn);
        }

        return $this->connection;
    }
263097
public function getConnection()
    {
        if (null === $this->_conn && null !== $this->_tableName) {

            $this->_conn = \Doctrine::getConnectionByTableName($this->_tableName);
        }

        return $this->_conn;
    }
928781
public function getDbalConnection()
    {
        $dbalDriver = '';
        $driverCode = $this->getDriver()->getCode();

        if ($driverCode === 'MySQL') $dbalDriver = 'pdo_mysql';
        if ($dbalDriver == '') return null;

        $config = new Configuration();
        $loggerChain = new LoggerChain();

        if (\Arvici\Heart\Config\Configuration::get('app.env') == 'development') {
            $loggerChain->addLogger(new DoctrineLogBridge(\Logger::getInstance()->getMonologInstance()));
            $loggerChain->addLogger(DebugBarHelper::getInstance()->getDebugStack());
        }
        $config->setSQLLogger($loggerChain);

        return DriverManager::getConnection([
            'driver' => $dbalDriver,
            'pdo' => $this
        ], $config);
    }
866005
public static function getDatabase()
    {
        $attribute = 'database';

        if (!static::hasClassAttribute($attribute)) {
            $database = Database::getDefault();

            if (!$database) {
                $error = static::error('connection', 'database not found', 'required-for', 6);
                switch (static::getClassConfig('error-mode')) {
                    case 'silent': break;
                    case 'exception': throw new Exception($error);
                    default: trigger_error($error, E_USER_ERROR);
                }
            }

            static::setClassAttribute($attribute, $database);
        }

        return static::getClassAttribute($attribute);
    }
793228
public function getConnection()
    {
        if( null === $this->connection && null !== $this->connectionFactory ) {
            $this->connection = $this->connectionFactory->createMysqli();
        }
        return $this->connection;
    }
855864
public function getConnection()
    {
        $repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig();
        // Taking provided connection name if any.
        // Otherwise, just fallback to the default connection.

        if (isset($repositoryConfig['search']['connection'])) {
            $doctrineConnectionId = sprintf('doctrine.dbal.%s_connection', $repositoryConfig['search']['connection']);
        } else {
            // "database_connection" is an alias to the default connection, set up by DoctrineBundle.
            $doctrineConnectionId = 'database_connection';
        }

        if (!$this->container->has($doctrineConnectionId)) {
            throw new InvalidArgumentException(
                "Invalid Doctrine connection '{$repositoryConfig['search']['connection']}' for repository '{$repositoryConfig['alias']}'." .
                'Valid connections are ' . implode(', ', array_keys($this->container->getParameter('doctrine.connections')))
            );
        }

        return $this->container->get($doctrineConnectionId);
    }
768745
public function getConnection()
    {
        if (!$this->connection) {
            if ($this->connectionName) {
                $this->connection = $this->mongator->getConnection($this->connectionName);
            } else {
                $this->connection = $this->mongator->getDefaultConnection();
            }
        }

        return $this->connection;
    }
150770
public static function connectDb() {
        if 
            (!isset(self::$dbLink)) {
            $dbParams = self::getDatabaseParameters();
            self::validateDbParameters($dbParams);
            $dbParamsSan = self::sanitizeDbParameters($dbParams);
            $config = new Configuration();
            self::$dbLink = DriverManager::getConnection($dbParamsSan, $config);
        }
        
        return self::$dbLink;
    }
1185757
public function getDoctrineConnection()
    {
        if (is_null($this->doctrineConnection)) {
            $data                     = ['pdo' => $this->getPdo(), 'user' => $this->getConfig('username')];
            $this->doctrineConnection = new DoctrineConnection(
                $data,
                $this->getDoctrineDriver()
            );
        }

        return $this->doctrineConnection;
    }