Select the database

@param	string	$database
@return	bool
359475
public function db_select($database = '')
	{
		if ($database === '')
		{
			$database = $this->database;
		}

		// Note: Escaping is required in the event that the DB name
		// contains reserved characters.
		if (mssql_select_db('['.$database.']', $this->conn_id))
		{
			$this->database = $database;
			return TRUE;
		}

		return FALSE;
	}
629522
public function select($database)
    {
        $this->database = $database;

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

        return $this;
    }
556389
protected function _select_db($database)
	{
		if ( ! mysql_select_db($database, $this->_connection))
		{
			// Unable to select database
			throw new \Database_Exception(mysql_error($this->_connection), mysql_errno($this->_connection));
		}

		static::$_current_databases[$this->_connection_id] = $database;
	}
1074373
public function getDatabase($databaseName = null) {
		if ($databaseName === null) {
			$databaseName = $this->dbname;
		}

		if (! isset($this->databases[$databaseName])) {
			$this->databases[$databaseName] = $this->getClient()->selectDB($databaseName);
		}

		return $this->databases[$databaseName];
	}
584428
protected function db($db = '')
    {
        $db = $db ? $db : $this->use_db;

        return Connection::getInstance($db);
    }
1116044
public function select($sql, $args = array())
    {
        return $this->build($this->db->select($sql, $args));
    }
66679
public function Fetch($Table = FALSE, $Database = NULL) {
      if ($Table !== FALSE)
         $this->CurrentTable = $Table;
      
      if (!is_array($this->_Schema))
         $this->_Schema = array();
         
      if (!array_key_exists($this->CurrentTable, $this->_Schema)) {
         if($Database !== NULL) {
            $SQL = $Database->SQL();
         }
         else {
            $SQL = Gdn::SQL();
         }
         $this->_Schema[$this->CurrentTable] = $SQL->FetchTableSchema($this->CurrentTable);
      }
      return $this->_Schema[$this->CurrentTable];
   }
839035
public function getTables($database=null)
    {
        if (empty($database)) $database = $this->getDatabase();
        
        $key  = 'db/tables/' . $database;
        $data = static::getCache()->get($key);
        if (!$data) {
            $data = $this->getAdapter()->getTables($database);
            static::getCache()->set($key, $data);
        }
        return $data;
    }
900076
public function checkDbExists($database)
    {
        try {
            $databaseExists = true;
            $database->execSql("select * from oxconfig");
        } catch (Exception $exception) {
            $databaseExists = false;
        }

        return $databaseExists;
    }
1052917
public function select($database)
	{
		$this->connect();

		if (!$database)
		{
			return false;
		}

		if (!sqlsrv_query($this->connection, 'USE ' . $database, null, array('scrollable' => SQLSRV_CURSOR_STATIC)))
		{
			throw new \RuntimeException('Could not connect to database');
		}

		return true;
	}
520287
public function select($index)
    {
        $response = $this->__call('select', [$index]);
        $this->database = (int) $index;

        return $response;
    }
438365
public function selectDatabase($name)
    {
        if ($this->eventManager->hasListeners(Events::preSelectDatabase)) {
            $this->eventManager->dispatchEvent(Events::preSelectDatabase, new EventArgs($this, $name));
        }

        $this->initialize();
        $database = $this->doSelectDatabase($name);

        if ($this->eventManager->hasListeners(Events::postSelectDatabase)) {
            $this->eventManager->dispatchEvent(Events::postSelectDatabase, new EventArgs($this, $database));
        }

        return $database;
    }
623891
private function _checkdatabase($database)
    {

        if (count($this->_collection) == 0) {
            $this->_collection[$database] = new $database();

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

        $new = false;
        foreach ($this->_collection as $db) {
            if ($db === $database) continue;
            $new = true;
        }

        if ($new === true) {
            $this->_collection[$database] = new $database();
        }

        return false;
    }
683546
public function getDatabase(string $database): DatabasePartial
    {
        if (!$this->hasDatabase($database)) {
            throw new ConfigException("Undefined database `{$database}`.");
        }

        $config = $this->config['databases'][$database];

        return new DatabasePartial(
            $database,
            $config['tablePrefix'] ?? $config['prefix'] ?? '',
            $config['connection'] ?? $config['write'] ?? $config['driver'],
            $config['readConnection'] ?? $config['read'] ?? $config['readDriver'] ?? null
        );
    }
93411
public function selectDB($name)
    {
        $this->dbname = $name;

        if ($this->phase !== self::PHASE_GOT_INIT) {
            return $this->query('USE `' . $name . '`');
        }

        return true;
    }
1362356
public function isExists(string $database, string $table)
    {
        return $this->select(
            '
            SELECT *
            FROM system.tables 
            WHERE name=\'' . $table . '\' AND database=\'' . $database . '\''
        )->rowsAsTree('name');
    }
33403
public function getTables($database=null)
    {
        if (is_null($this->tables)) {
            $sql    = !empty($database) ? 'SHOW TABLES FROM '.$database : 'SHOW TABLES';
            $this->query($sql);
            $result = $this->fetchAll();
            foreach ($result as $v) {
                $this->tables[] = array_values($v)[0];
            }
        }
        return $this->tables;
    }