Returns the database connection for this component.
@return \CDbConnection the connection component.
@throws \CException if the component does not exist or is not an instance of CDbConnection.
779049
public function getDbConnection()
    {
        if (!Yii::app()->hasComponent($this->connectionID)) {
            throw new CException(sprintf('Connection component "%s" does not exist.', $this->connectionID));
        }
        $db = Yii::app()->getComponent($this->connectionID);
        if (!$db instanceof CDbConnection) {
            throw new CException(sprintf(
                'Connection component "%s" is not an instance of CDbConnection.',
                $this->connectionID
            ));
        }
        return $db;
    }
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;
    }
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);
    }
1323180
public function connection()
    {
        if (!is_object($this->db)) {
            $this->db = new DB;
            $this->db->addConnection($this->database);
            $this->db->setEventDispatcher(new Dispatcher(new Container));
            $this->db->setAsGlobal();
            $this->db->bootEloquent();
        }

        return $this;
    }
364007
public function getConnection()
    {
        if ($this->connection instanceof ConnectionInterface === FALSE)
        {
            $this->connection = Propel::getConnection();
        }

        return $this->connection;
    }
239919
public function getConnection()
    {
        if(!$this->_connection) {
            $this->_connection = new \Guzzle\Http\Client($this->getHost());
        }

        return $this->_connection;
    }
1105061
public function getDoctrineConnection()
    {
        $driver = $this->getDoctrineDriver();

        $data = array('pdo' => $this->pdo, 'dbname' => $this->getConfig('database'));

        return new DoctrineConnection($data, $driver);
    }
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);
    }
166450
public function connection()
	{
		if ( empty($this->connection))
		{
			$this->connection = $this->createConnection();
		}

		return $this->connection;
	}
679556
public function getConnection()
    {
        if (!$this->connection) {
            if ($this->connectionName) {
                $this->connection = $this->mandango->getConnection($this->connectionName);
            } else {
                $this->connection = $this->mandango->getDefaultConnection();
            }
        }

        return $this->connection;
    }
793228
public function getConnection()
    {
        if( null === $this->connection && null !== $this->connectionFactory ) {
            $this->connection = $this->connectionFactory->createMysqli();
        }
        return $this->connection;
    }
1344496
static public function connection($name = null)
    {
        if ($name === null) {
            $name = self::$activeConnectionName;
            
            if (!$name) {
                if (self::$defaultConnectionName) {
                    $name = self::$defaultConnectionName;
                    self::setConnection($name);
                    self::$defaultConnectionName = null;
                } else {
                    throw new Exception\RuntimeException("No database connection is active");
                }
            }
        } else {
            self::create_connection($name);
        }
        
        return self::$_connections[$name];
    }
1337263
public function getConnection()
    {
        // Initiate connection if not exist
        if ($this->connection === null) {
            $this->connection = DriverManager::getConnection($this->dsn);
        }

        return $this->connection;
    }
975348
public function getConnection()
    {
        try {
            if ($this->instancia == null) {

                $json = new JsonReader(BASE_DIR . self::PATH_CONFIG_FILE);

                if (!empty(glob(dirname(__DIR__, 4) . self::PATH_CONFIG_FILE )[0])) {
                    $json = new JsonReader(glob(dirname(__DIR__, 4) . PATH_CONFIG_FILE)[0]);
                }

                $json= $json->read();
                try {

                    $connectionCache = $json->phiber->link->connection_cache == 1 ? true : false;

                    $this->instancia = new PDO(
                        $json->phiber->link->url,
                        $json->phiber->link->user,
                        $json->phiber->link->password,
                        array(
                            PDO::ATTR_PERSISTENT => $connectionCache
                        )
                    );
                } catch (PhiberException $e) {
                    throw new PhiberException(new Internationalization("database_connection_error"));
                }
            }

            return $this->instancia;

        } catch (PhiberException $e) {
            throw new PhiberException(new Internationalization("database_connection_error"));
        }
    }
162908
private function getConnection()
    {
        if (!isset($this->connections[$this->getDriver()])) {
            $this->connections[$this->getDriver()] = DriverManager::getConnection(
                array(
                    'driver' => $this->getDriver(),
                    'host' => str_replace('pdo_', '', $this->getDriver()),
                    'dbname' => 'list',
                    'user' => 'list',
                    'password' => 'list',
                    // 'unix_socket' => '/tmp/mysql.sock',
                )
            );
        }

        return $this->connections[$this->getDriver()];
    }
23010
public function connect(): self
    {
        if ($this->pdoInstance !== null) {
            return $this;
        }

        // Build a database connection if we don't have one connected
        $this->setPdoInstance($this->getAdapter()->connect($this->getAdapterConfig()));

        return $this;
    }
1134882
public static function getDefaultConnection()
    {
        if (self::$defaultConnection === null) {
            $databaseSettings = StemSettings::singleton();

            self::$defaultConnection = static::getConnection($databaseSettings);

            if ($databaseSettings->stickyWriteConnection) {
                self::$readOnlyConnection = self::$defaultConnection;
            }
        }

        return self::$defaultConnection;
    }