Set a DB connection to use when compiling the SQL

@param  mixed  $db

@return  $this
438364
public function set_connection($db)
	{
		if ( ! $db instanceof \Database_Connection)
		{
			// Get the database instance
			$db = \Database_Connection::instance($db);
		}
		$this->_connection = $db;

		return $this;
	}
725132
public function connectToDb()
    {
        $this->con = new PDO("mysql:host=$this->host", $this->username, $this->password);
        $this->con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $this->con->query("CREATE DATABASE IF NOT EXISTS " . $this->dbName);
        $this->con->query("USE " . $this->dbName);
    }
596591
public function setPdo($pdo)
    {
        $this->connection = $this->createConnection();
        $this->getManagedConfigure($this->config);
        $this->useDefaultQueryGrammar();
        $this->useDefaultPostProcessor();

        return $this;
    }
236889
protected function updateConnection($connection)
    {
        if ($this->connection !== $connection) {
            $this->connection  = $connection;
            $this->schemaSetUp = false;
        }

        return $this;
    }
638880
public function db($db = null)
    {
        if ($db === null)
        {
            return $this->_db;
        }
        $this->_db = $db;

        return $this;
    }
1366888
public function setConnection($connection)
    {
        $this->connection = $connection;
        $this->database = DB::connection($this->connection);
        return $this;
    }
213722
public function setDatabase($database)
    {
        $database = empty($database)
            ? $this->database
            : $database;

        if (is_file($database)) {
            $this->handle->open($database);
            $this->database = $database;
        }

        return $this;
    }
1329207
protected static function _setupDb($connection_name = self::DEFAULT_CONNECTION)
        {
            if (!Arrays::exists($connection_name, self::$_db) || !is_object(self::$_db[$connection_name])) {
                self::_setupDbConfig($connection_name);

                $db = new PDO(
                    self::$_config[$connection_name]['connection_string'],
                    self::$_config[$connection_name]['username'],
                    self::$_config[$connection_name]['password'],
                    self::$_config[$connection_name]['driver_options']
                );

                $db->setAttribute(PDO::ATTR_ERRMODE, self::$_config[$connection_name]['error_mode']);

                self::set_db($db, $connection_name);
            }
        }
953270
public function setDatabase($database)
    {
        if (is_string($database)) {
            $database = $this->db->getDatabase($database);
        }

        $this->database = $database;

        return $this;
    }
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;
    }
74870
public static function db()
    {
        self::$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        return self::$conn;
    }
396290
public function exec(Db $db) {
        $options = [
            'limit' => $this->limit,
            'offset' => $this->offset
        ];

        $r = $db->get($this->from, $this->where, $options);
        return $r;
    }
938738
public function setSourceDB(DB $db)
    {
        if ($db === null)
            throw new \InvalidArgumentException("Source database must not be null");
        $this->_source_db = $db;
        return $this;
    }
5332
public function database($database, $wrap = true)
    {
        $database = $this->connection->{$database};

        return $wrap ? new Database($database, $this) : $database;
    }
1255544
public function setDB(DBAdapter $v)
    {
        $this->db = $v;
        foreach ($this->clauses as $clause) {
            $clause->setDB($v);
        }
    }
629522
public function select($database)
    {
        $this->database = $database;

        $this->getDatabase($database)->select();

        return $this;
    }
1127201
public function change(string $db): self
  {
    if ( $this->language->change($db) ){
      $this->current = $db;
    }
    return $this;
  }