Set the database to use with this connection

Sets the database to use with this connection, for example: 'my_database'<br>
Further calls to the database will be addressed to the given database.

@param string $database the database to use
491479
public function setDatabase($database)
    {
        $this->_options[ConnectionOptions::OPTION_DATABASE] = $database;
        $this->_database                                    = $database;

        $this->updateHttpHeader();
    }
8475
public function setDatabase(string $dbName): bool
    {
        $this->db->exec('USE ' . $this->quoter->quoteName($dbName) . ';');

        return true;
    }
348496
protected function initDatabase()
    {
        $dbConfig = (array) config("database");

        if (count($dbConfig) > 0) {
            $this->db = new Database($dbConfig);
            Model::$db = $this->db;
        }
    }
812112
def set_database(self, db):
        '''
        
        '''
        # This can not be imported globally due to circular import
        from .database import Database
        assert isinstance(db, Database), "database must be database.Database instance"
        self._database = db
80945
public function setNewDatabase($configuration): void
    {
        if ($configuration instanceof Configurator) {
            $this->db = new Db($configuration);
        } else {
            $this->db = new Db(new Configurator($configuration));
        }
    }
125247
public function drop_database($database) {
		$query = 'DROP DATABASE ' . $this->quote_identifier($database);
		$statement = $this->get_statement($query);

		$statement->execute();
	}
245877
public function setSql($sql)
    {
        $startTime = microtime(true);
        if ($this->result) {
            $startTime = $this->result->getStart();
        }
        $this->result = new Result();
        $this->result->setStart($startTime);
        if ($sql) {
            $sql = SqlFormatter::compress($sql);
            $this->sql = trim($sql, '; ');
            $this->setCommand($this->sql);
        }
    }
890948
public function connectionTo($key, $database)
    {
        Config::set("database.connections.{$key}.database", $database);

        $this->reconnect($key, $database);
    }
1247366
public function select_database($database)
    {
        //        try{

        if ($this->pdo) {
            if ($this->pdo->exec('USE ' . $database) !== FALSE) {
                return true;
            }
        }
        //        }catch(\Exception $ex)
        //        {
        //            new Exception($this->getLastError());
        //        }
        return false;
    }
390545
public function createDatabase($database=null)
    {
        if (!$database) $database = $this->getDatabase();
        $sql = $this->getSchema()->getCreateDatabaseSql($database);
        return $this->query($sql);
    }
640202
public function setConnection(Connection $connection)
    {
        if (! in_array($connection, $this->_connections, true)) {
            $this->_connections[] = $connection;
        }
    }
166907
public function setDatabase($dbname)
    {
        $this->config->setDatabase($dbname);
        if ($this->connection) {
            try {
                $this->query('USE ' . $this->quote()->identifier($dbname));
            } catch (RuntimeException $exception) {
                /** @var \PDOException $prevException */
                $prevException = $exception->getPrevious();
                if (UnknownDatabaseException::isUnknownDatabase($prevException)) {
                    throw UnknownDatabaseException::createFromUnknownDatabase($dbname, $prevException);
                }

                throw $exception;
            }
        }

        return $this;
    }
1109443
public function setConnection($name)
    {
        if (! is_null($name)) {
            $this->resolver->setDefaultConnection($name);
        }

        $this->repository->setSource($name);

        $this->connection = $name;
    }
1212480
final public static function setInstance($instance)
    {
        if ($instance instanceof PDO) {
            $instance = $instance->getAttribute(PDO::ATTR_DRIVER_NAME);
        }
        if (is_string($instance)) {
            if (class_exists('SQL\Writer\\' . $instance)) {
                $class = 'SQL\Writer\\' . $instance ;
                $instance = new $class;
            } else {
                $instance = new self;
            }
        }

        if (!($instance instanceof self)) {
            throw new RuntimeException('$instance must an instanceof SQL\Writer');
        }

        self::$instance = $instance;
    }
439300
public function create_database($database) {
		$query = 'CREATE DATABASE ' . $this->quote_identifier($database);
		$statement = $this->get_statement($query);

		$statement->execute();
	}
1342748
public static function setDriver($driver)
        {
            if (self::isDriverSupported($driver) == false) {
                throw new Exception('The selected database is not supported: "' . $driver . '".');
            }
            self::$driver = $driver;
        }
556875
public function setDatabase($database){

        $file = XS_APP_ROOT.'/xunsearch.php';
        if(!file_exists($file)){
            throw new \Exception('配置文件'.$file.'不存在');
        }
        $config = include $file;
        if(!isset($config['databases'][$database])){
            throw new \Exception('配置文件'.$file.'缺少这个'.$database.'配置');
        }

        $this->database = $database;

        $config = $config['databases'][$database];

        return $this->setConfig($config);

    }