Get a database connection configuration.

@param  string $connection
@return array
@throws \Exception
425339
protected function getDatabaseConnectionConfig($connection)
    {
        $connections = $this->proxy->get('database.connections');
        if (!isset($connections[$connection])) {
            throw new Exception('Unknown database connection: ' . $connection);
        }
        $config = $connections[$connection];
        if (!in_array($config['driver'], ['mysql', 'pgsql'])) {
            throw new Exception('Currently only MySQL and PostgreSQL databases are supported using the laravel config');
        }
        return $config;
    }
828950
public function getColumns($table, $connection = null)
    {
        $this->updateConnection($connection)->setUpDoctrineSchema();

        $schema  = $this->getSchemaBuilder();
        $columns = $schema->getColumnListing($table);

        $columnData = [];

        foreach ($columns as $name) {

            $column = $schema->getConnection()->getDoctrineColumn($table, $name);

            $columnData[] = [
                'name'     => $column->getName(),
                'type'     => $column->getType()->getName(),
                'length'   => $column->getLength(),
                'values'   => false,
                'unsigned' => $column->getUnsigned(),
                'nullable' => ! $column->getNotnull(),
            ];
        }

        return $columnData;
    }
588885
protected function getConnection()
    {
        $generatorConfig = $this->getGeneratorConfig();
        $database = $generatorConfig->getConfigProperty('reverse.connection');

        if (null === $database) {
            throw new BuildException('No configured connection. Please add a connection to your configuration file
            or pass a `connection` option to your command line.');
        }

        return $generatorConfig->getConnection($database);
    }
478033
public function queryBuilder($connection = null)
    {
        $key = $connection ?? $this->defaultConnection;

        if (!isset($this->queryBuilders[$key]))
        {
            $this->connection($key); // init connection
            $this->queryBuilders[$key] = new QueryBuilder($this->adapterProviders[$key]);
        }

        return $this->queryBuilders[$key];
    }
1248489
public function getConnection(?string $connection = 'local', array $options = []): AbstractDatabaseDriver
    {
        $key = 'connection.' . $connection;

        if (!$this->container->has($key)) {
            $this->container->share($key, $this->createConnection($connection, $options));
        }

        return $this->container->get($key);
    }
1161492
public static function build(string $connectionName = null) : Connection
    {
        $configs = Application::current()->config('database');
        $connectionName = $connectionName ?: $configs['default'];

        if (!isset($configs[$connectionName])) {
            throw new \Exception("Unknown database connection: '$connectionName'");
        }

        if (!isset(self::$connections[$connectionName])) {
            $connectionClass = $configs[$connectionName]['driver'];
            $options = $configs[$connectionName]['options'];
            self::$connections[$connectionName] = new $connectionClass($options);
        }

        return self::$connections[$connectionName];
    }
926690
public function getDatabase(string $connection = 'default'): Database
    {
        if (!isset($this->database[$connection])) {
            $this->database[$connection] = new Database($this->getConnection($connection));
        }

        return $this->database[$connection];
    }
1306659
public function connection($connection = null)
    {
        $type = $connection ?? $this->defaultConnection;

        if (!isset($this->connection[$type]))
        {
            $slice = $this->slice->getSlice($type);

            $key     = $slice->getRequired('adapter');
            $adapter = $this->adapters[$key];

            $this->adapterProviders[$type] = new $adapter();

            $this->adapterProviders[$type]->setHost($slice->getData('host'));
            $this->adapterProviders[$type]->setPort($slice->getData('port'));

            if (method_exists($this->adapterProviders[$type], 'setPath'))
            {
                $this->adapterProviders[$type]->setPath($slice->getData('path'));
            }

            $this->adapterProviders[$type]->setDbName($slice->getData('database'));

            $this->adapterProviders[$type]->setConnection($this);

            $this->adapterProviders[$type]->setPDOClass(Connection::class);

            $options = [
                Connection::ATTR_DEFAULT_FETCH_MODE => Connection::FETCH_ASSOC,
                //Connection::ATTR_EMULATE_PREPARES   => true,
                //Connection::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
                //Connection::ATTR_PERSISTENT         => false,
                //Connection::MYSQL_ATTR_INIT_COMMAND       => 'SET NAMES utf8mb4'
            ];

            if ($this->adapterProviders[$type]->name() !== 'sqlite')
            {
                $options[Connection::ATTR_ERRMODE] = Connection::ERRMODE_EXCEPTION;
            }

            $this->connection[$type] = $this->adapterProviders[$type]->connection(
                $slice->getData('username'),
                $slice->getData('password'),
                $slice->getData('options', $options)
            );
        }

        return $this->connection[$type];
    }
38008
protected function
	GetConnectionConfig($Alias) {
	/*//
	@return Nether\Database\Connection
	fetch the specified configuration. if none is found then it will throw an
	exception instead.
	//*/

		$Config = Nether\Option::Get('nether-database-connections');

		if(!array_key_exists($Alias,$Config))
		throw new Nether\Database\Error\InvalidConfig($Alias);

		if($Config[$Alias] instanceof Nether\Database\Connection)
		return $Config[$Alias];

		return new Nether\Database\Connection($Config[$Alias]);
	}
1047963
protected function configuration($name)
    {
        $name = $name ?: $this->getDefaultConnection();

        // To get the database connection configuration, we will just pull each of the
        // connection configurations and get the configurations for the given name.
        // If the configuration doesn't exist, we'll throw an exception and bail.
        $connections = $this->container['config']['database.connections']->toArray();

        if (is_null($config = Arr::get($connections, $name))) {
            throw new InvalidArgumentException("Database [$name] not configured.");
        }

        return $config;
    }
538091
public function findByConnection($connection)
    {
        return $this->first(function ($client, $key) use ($connection) {
            return $client->connection === $connection;
        });
    }
680306
public function initConnection(Connection $connection)
    {
        /** @var $pdo PDO */
        $pdo = $connection->getWrappedConnection();
        $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
        $params = $connection->getParams();
        if (!isset($params['charset'])) {
            throw new RuntimeException("No connection charset specified");
        }
        $pdo->exec('SET NAMES ' . $pdo->quote($params['charset']));
    }
1204751
protected function getDatabaseSize($connection)
    {
        switch ($this->getDriverName($connection)) {
            case 'mysql':
                $size = $this->checkMySqlDatabaseSize($connection);
                break;
            case 'sqlite':
                $size = $this->checkSqLiteDatabaseSize($connection);
                break;
            case 'pgsql':
                $size = $this->checkPostgresDatabaseSize($connection);
                break;
            case 'sqlsrv':
                $size = $this->checkSqlServerDatabaseSize($connection);
                break;
            default:
                $this->eye->logger()->debug('Unable to find DB driver for size', $connection);
                return -1;
        }

        return round($size/1024/1024, 2);
    }
1119794
public function return_connection($connection) {
        if ($connection->op_count >= $this->recycle) {
            $this->stats['recycled'] += 1;
            $connection->close();
            $this->make_conn();
            $connection = $this->get();
        }
        array_push($this->queue, $connection);
    }
369559
public function getAll(Connection $connection): array
    {
        foreach ($this->registry as $types) {
            foreach (array_keys($types) as $type) {
                $this->get($connection, $type);
            }
        }

        return $this->instances[$connection->driver()];
    }
176641
public function getDatabaseMetadata(
        Connection $connection,
        string $databaseName
    ): DatabaseMetadata {
        // Get a list of table names
        $tableNameStatement = $connection
            ->createQueryBuilder()
            ->select([
                'tables.TABLE_NAME AS name'
            ])
            ->from('information_schema.TABLES', 'tables')
            ->where('TABLE_SCHEMA = :schema')
            ->andWhere('TABLE_TYPE = "BASE TABLE"')
            ->setParameter('schema', $databaseName)
            ->execute();

        // Build table metadata
        $tableMetadataList = [];
        while ($tableName = $tableNameStatement->fetchColumn(0)) {
            $tableMetadataList[] = $this->getTableMetadata($connection, $databaseName, $tableName);
        }

        return new DatabaseMetadata($databaseName, $tableMetadataList);
    }
1241642
public function getBuildConnection($database)
    {
        if (!isset($this->buildConnections[$database])) {
            // fallback to default connection settings from build.properties
            return array(
                'dsn'      => $this->url,
                'user'     => $this->userId,
                'password' => $this->password,
            );
        }

        return $this->buildConnections[$database];
    }