Add a database to the list and sets the AppData property to this
AppData

@param Database|string $db the database to add

@return Database
190802
public function addDatabase($db)
    {
        if ($db instanceof Database) {
            $db->setAppData($this);
            if ($db->getPlatform() === null) {
                if ($config = $this->getGeneratorConfig()) {
                    $pf = $config->getConfiguredPlatform(null, $db->getName());
                    $db->setPlatform($pf ? $pf : $this->platform);
                } else {
                    $db->setPlatform($this->platform);
                }
            }
            $this->dbList[] = $db;

            return $db;
        } else {
            // XML attributes array / hash
            $d = new Database();
            $d->setAppData($this);
            $d->loadFromXML($db);

            return $this->addDatabase($d); // calls self w/ different param type
        }
    }
10296
public function setDbConn($dbconfig = [])
    {
        if (empty($dbconfig)) {
            $this->dbconfig = config('database');
            //$this->dbconfig = Config::get('database');
        } else {
            $this->dbconfig = $dbconfig;
        }
        return $this;
    }
366049
public function setAssetsDb(array $db)
    {
        foreach ($db as $package_name=>$package) {
            if (empty($package['path']) && isset($package['relative_path'])) {
                $db[$package_name]['path'] = DirectoryHelper::slashDirname(
                    DirectoryHelper::slashDirname($this->getRootDirectory()) .
                    DirectoryHelper::slashDirname($this->getAssetsDirectory()) .
                    DirectoryHelper::slashDirname($this->getAssetsVendorDirectory()) .
                    $package['relative_path']
                );
            }
        }
        $this->assets_db = $db;
        return $this;
    }
143239
public void addDatabase(Database database)
    {
        if (m_databaseCollection == null)
            m_databaseCollection = new DatabaseCollection(this);
        m_databaseCollection.addDatabase(database);
    }
390545
public function createDatabase($database=null)
    {
        if (!$database) $database = $this->getDatabase();
        $sql = $this->getSchema()->getCreateDatabaseSql($database);
        return $this->query($sql);
    }
491479
public function setDatabase($database)
    {
        $this->_options[ConnectionOptions::OPTION_DATABASE] = $database;
        $this->_database                                    = $database;

        $this->updateHttpHeader();
    }
960942
public function dropDatabase($database)
    {
        if ($this->eventManager->hasListeners(Events::preDropDatabase)) {
            $this->eventManager->dispatchEvent(Events::preDropDatabase, new EventArgs($this, $database));
        }

        $this->initialize();
        $result = $this->mongoClient->dropDB($database);

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

        return $result;
    }
494558
public function generate(...$database)
    {
        $databases = $this->getDatabaseList($database);

        foreach( $databases as $connection => $database )
        {
            $this->setDatabaseConfiguration($connection, $database, $configs);

            $this->createVisionDirectoryByDatabaseName($database);

            $this->createVisionModelFile($database, $configs);
        }
    }
724580
public function createDatabase($domainName, \Transip\Model\Db $db)
    {
        return $this->getSoapClient(array_merge(array($domainName, $db), array('__method' => 'createDatabase')))->createDatabase($domainName, $db);
    }
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);

    }
566935
def createDatabase( dbname, dbdesc, createapptoken = "1" )

      @dbname, @dbdesc, @createapptoken = dbname, dbdesc, createapptoken

      xmlRequestData = toXML( :dbname, @dbname )
      xmlRequestData << toXML( :dbdesc, @dbdesc )
      xmlRequestData << toXML( :createapptoken, @createapptoken )

      sendRequest( :createDatabase, xmlRequestData )

      @dbid = getResponseValue( :dbid )
      @appdbid = getResponseValue( :appdbid )
      @apptoken = getResponseValue( :apptoken )

      return self if @chainAPIcalls
      return @dbid, @appdbid
   end
758264
public function setDb( string $db ) : SQLite
   {

      if ( ! $this->_supportedAttributes->get( 'db' )->validateValue( $db ) )
      {
         throw new ArgumentException( 'db', $db, 'Invalid database!' );
      }

      $this->_attributes[ 'db' ] = $db;

      return $this;

   }
779821
public function insert($db = null)
    {
        $this->getDAO($this->getDB($db))->save($this);
        return $this;
    }
204291
protected function _select_db($database)
	{
		if ($this->_config['connection']['database'] !== static::$_current_databases[$this->_connection_id])
		{
			if ($this->_connection->select_db($database) !== true)
			{
				// Unable to select database
				throw new \Database_Exception($this->_connection->error, $this->_connection->errno);
			}
		}

		static::$_current_databases[$this->_connection_id] = $database;
	}
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
        );
    }
629522
public function select($database)
    {
        $this->database = $database;

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

        return $this;
    }
12112
public function switchDb($db_name)
    {
        $self = $this;

        return $this->app['mongo'] = $this->app->share(
            function () use ($db_name, $self) {
                return new Db($db_name, $self->client, $self->app);
            }
        );
    }