Adds the Connection to the Pool

@param [type] $connection [description]
@return  connection
337932
public function addConnection(\Nofuzz\Database\PdoConnectionInterface $connection)
  {
    $this->connections[strtolower($connection->getName())] = $connection;

    return $connection;
  }
788487
public function setConnection(Connection $connection)
    {
        $this->connection = $connection;
        $this->prefix     = $this->connection->getConfig('prefix');

        return $this;
    }
662297
private function connect()
    {
        if (is_null($this->connection)) {
            $this->connection = call_user_func($this->connectionFactory, $this->config);
        }

        return $this;
    }
1222900
public function newFromBuilder($attributes = array(), $connection = null)
    {
        // hide ref_id from model, because ref_id == id
        $attributes = array_except((array) $attributes, $this->getVersionKeyName());

        return parent::newFromBuilder($attributes, $connection);
    }
556769
public function addConnection(string $name = null, Connection $connection = null): self
    {
        if (is_null($name)) {
            $this->defaultConnection = $connection;
        } else {
            $this->registry[$name] = $connection;
        }

        return $this;
    }
216550
public function createConnection(?string $connection = null, array $options = []): AbstractDatabaseDriver
    {
        $config = $this->config->extract('database');

        // Check is new or legacy
        if ($config->get('connections')) {
            $connection = $connection ?: $config->get('default', 'local');
            $config     = $config->extract('connections.' . $connection);
        }

        $options = array_merge(
            [
                'driver' => $config->get('driver', 'mysql'),
                'host' => $config->get('host', 'localhost'),
                'user' => $config->get('user', 'root'),
                'password' => $config->get('password', ''),
                'database' => $config->get('name'),
                'prefix' => $config->get('prefix', 'wind_'),
            ],
            $options
        );

        $db = DatabaseFactory::getDbo($options['driver'], $options, true);

        $db->setDebug($this->config->get('system.debug', false));

        if ($db instanceof MysqlDriver && $config->get('strict', true)) {
            $this->strictMode($db);
        }

        return $db;
    }
1339400
public function connection($connection)
	{
		$connections = Config::get('database.connections');

		$default = Config::get('database.default');

		$connection = $connections[$default];

		$connectionString = "{$connection['driver']}:host={$connection['host']};dbname={$connection['database']}";

		try 
		{
			$pdo = new PDO($connectionString, $connection['username'], $connection['password']);
		}
		catch (PDOException $e)
		{
			print "Error!: " . $e->getMessage() . "<br/>";
			die();
		}

		$db = new Qlake\Database\Query(new Qlake\Database\Connection($pdo), new Qlake\Database\Grammar);

		return $db;
	}
624291
protected function prepare(Connection $connection)
	{
		$connection->setFetchMode($this->app['config']['database.fetch']);

		if ($this->app->bound('events'))
		{
			$connection->setEventDispatcher($this->app['events']);
		}

		// The database connection can also utilize a cache manager instance when cache
		// functionality is used on queries, which provides an expressive interface
		// to caching both fluent queries and FlyORM queries that are executed.
		$app = $this->app;

		$connection->setCacheManager(function() use ($app)
		{
			return $app['cache'];
		});

		// We will setup a Closure to resolve the paginator instance on the connection
		// since the Paginator isn't sued on every request and needs quite a few of
		// our dependencies. It'll be more efficient to lazily resolve instances.
		$connection->setPaginator(function() use ($app)
		{
			return $app['paginator'];
		});

		return $connection;
	}
216398
public function connection(?string $connection = null)
	{
		$connection = $connection ?? $this->default;

		if(!isset($this->connections[$connection]))
		{
			$this->connections[$connection] = $this->connect($connection);
		}

		return $this->connections[$connection];
	}
352610
public function connection()
    {
        if (!is_object($this->db)) {
            $this->db = new \MysqliDb();
            $this->db->addConnection($this->dbName, $this->database);
        }

        return $this;
    }
404330
protected static function build( $connection ) {
		$connections = static::connections();

		if ( empty( $connections[ $connection ] ) ) {
			throw new ConnectionNotFoundException();
		}

		static::$instances[ $connection ] = new Queue( $connections[ $connection ] );

		return static::$instances[ $connection ];
	}
640202
public function setConnection(Connection $connection)
    {
        if (! in_array($connection, $this->_connections, true)) {
            $this->_connections[] = $connection;
        }
    }
201622
public function connection($connection = null)
    {
        $connection = $connection ?: $this->getDefaultConnection();

        if (is_null($connection)) {
            throw new \InvalidArgumentException(sprintf('Unable to resolve NULL connection for [%s].', get_called_class()));
        }

        // If the given connection has not been created before, we will create the instances
        // here and cache it so we can return it next time very quickly. If there is
        // already a connection created by this name, we'll just return that instance.
        if (! isset($this->connections[$connection])) {
            $this->connections[$connection] = $this->createConnection($connection);
        }

        return $this->connections[$connection];
    }
216702
public function client($connection = null)
    {
        $connection = $connection ?: $this->setting('connection');
        return $this->git->connection($connection);
    }
1080119
protected function addActiveConnection(ConnectionInterface $connection)
    {
        if (!$this->activeConnections) {
            $this->activeConnections = new \SplObjectStorage;
        }
        $this->activeConnections->attach($connection);
    }
1072711
public static function getConnections($connection, $table)
    {
        $connections = DB::connection($connection)->table($table)->get();

        if(!empty($connections)) {
            /**
             * Create an empty array which will get populated with the data from
             * $connections in the correct format within the foreach statement
             * below file generation.
             */
            $config = array();
            /**
             * Generate a random string for the filename as it is temporary
             * and more secure.
             */
            $random_string = ConnectionLoader::random_string(35);
            /**
             * Append the .php extension to the file name and store here
             * storage_path/app/$tempFile with some starting content.
             */
            $tempFileName = $random_string . '.php';
            $tempFile = Storage::disk('local')->put($tempFileName, '<?php return ');

            if ($tempFile === true) {
                /**
                 * Loops through the connections checking the driver and pushes
                 * correctly formatted array into the $config array.
                 */
                foreach ($connections as $connection) {
                    $name = $connection->name;
                    $driver = $connection->driver;

                    if ($driver == 'sqlite') {

                        $connection_config = array(
                            'driver' => $driver,
                            'database' => database_path($connection->database),
                            'prefix' => $connection->prefix,
                        );

                        $config[$name] = $connection_config;

                    } elseif ($driver == 'mysql') {

                        $strict = $connection->strict;
                        if ($strict == 1) {
                            $strict = true;
                        } else {
                            $strict = false;
                        }
                        $password = $connection->password;

                        if(empty($password)) {
                            $connection_config = array(
                                'driver' => $driver,
                                'host' => $connection->host,
                                'database' => $connection->database,
                                'username' => $connection->username,
                                'password' => $password,
                                'charset' => $connection->charset,
                                'collation' => $connection->collation,
                                'prefix' => $connection->prefix,
                                'strict' => $strict,
                            );
                        }
                        else {
                            $connection_config = array(
                                'driver' => $driver,
                                'host' => $connection->host,
                                'database' => $connection->database,
                                'username' => $connection->username,
                                'password' => Crypt::decrypt($password),
                                'charset' => $connection->charset,
                                'collation' => $connection->collation,
                                'prefix' => $connection->prefix,
                                'strict' => $strict,
                            );
                        }

                        $config[$name] = $connection_config;

                    } elseif ($driver == 'pgsql') {

                        $password = $connection->password;

                        if(empty($password)) {
                            $connection_config = array(
                                'driver' => $driver,
                                'host' => $connection->host,
                                'port' => $connection->port,
                                'database' => $connection->database,
                                'username' => $connection->username,
                                'password' => $password,
                                'charset' => $connection->charset,
                                'prefix' => $connection->prefix,
                                'schema' => $connection->schema,
                            );
                        }
                        else {
                            $connection_config = array(
                                'driver' => $driver,
                                'host' => $connection->host,
                                'port' => $connection->port,
                                'database' => $connection->database,
                                'username' => $connection->username,
                                'password' => Crypt::decrypt($password),
                                'charset' => $connection->charset,
                                'prefix' => $connection->prefix,
                                'schema' => $connection->schema,
                            );
                        }

                        $config[$name] = $connection_config;
                    }
                }

                /**
                 * Append a var_export of $config to the temporary file and
                 * append the semicolon.
                 *
                 * Returns the temporary filename.
                 */
                $endFile = ';';
                Storage::append($tempFileName, var_export($config, true));
                Storage::append($tempFileName, $endFile);

                return $tempFileName;

            } else {
                \error_log('Unable to create temporary file');
            }
        } else {
            \error_log('Configuration File Connection Invalid.');
            return null;
        }
    }
375138
public function addConnection(ConnectionInterface $connection)
    {
        // TODO: This should be a pool of connections


        if ($connection->isReadable()) {
            $this->readConnection = $connection;
        }

        if ($connection->isWritable()) {
            $this->writeConnection = $connection;
        }
    }