Switch database.

@param string $dbName

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

        return true;
    }
1354027
def alter_database(self, dbname, db):
    
    self.send_alter_database(dbname, db)
    self.recv_alter_database()
772104
public function setDatabase($database = [], $name = 'default')
    {
        $this->database = $database;
        $this->dbName   = $name;

        return $this;
    }
606106
public function connect($type, $host, $dbname = '', $username = null, $password = null, array $options = array())
    {
        if ($this->PDO) {
            // If this object already has a PDO object, don't attempt a new connection
            return $this;
        }

        $dsn = '';

        if ($type == 'sqlite') {
            $dsn = "{$type}:{$host}";
        } else {
            $dsn = "{$type}:host={$host};dbname={$dbname}";
        }
        $PDO = new PDO($dsn, $username, $password, $options);

        if (!$PDO) {
            return false;
        }

        $this->PDO = $PDO;

        $this->setEscapeChar();
        return $this;
    }
925427
public function createTbl($dbname, $sql)
    {
        if (isset($dbname) && !empty(trim($dbname)) && isset($sql) && !empty(trim($sql))) {
            $this->db->exec("USE `{$dbname}` ");

            $this->db->exec($sql);

            return true;
        } else {
            return false;
        }
    }
150770
public static function connectDb() {
        if 
            (!isset(self::$dbLink)) {
            $dbParams = self::getDatabaseParameters();
            self::validateDbParameters($dbParams);
            $dbParamsSan = self::sanitizeDbParameters($dbParams);
            $config = new Configuration();
            self::$dbLink = DriverManager::getConnection($dbParamsSan, $config);
        }
        
        return self::$dbLink;
    }
926175
public function provideConnection(string $connectionName = ''): \PDO
    {
        if (empty($connectionName)) {
            $connectionName = $this->defaultConnectionName;
        }
        if ($this->hasConnection($connectionName) === true) {
            return $this->getConnection($connectionName);
        }

        $dbConfig = $this->credentials[$connectionName];

        switch ($dbConfig['driver']) {
            case 'mysql':
                $adapter = new PdoMysql;
                break;
            default:
                throw new DatabaseException('Unsupported database driver. Check config.');
        }

        $connection = $adapter->connect($dbConfig);
        $this->addConnection($connectionName, $connection);

        return $connection;
    }
796598
public function getDatabaseMetadata(string $databaseName): DatabaseMetadata
    {
        if (!array_key_exists($databaseName, $this->databaseMetadataList)) {
            throw new \RuntimeException('Server "' . $this->host . '" doesn\'t contain database "' . $databaseName . '"');
        }

        return $this->databaseMetadataList[$databaseName];
    }
792176
public function convertToPdo(string $server, ?string $dbName = null): \PDO
    {
        [$user, $address] = explode('@', $server);

        $explodedUser = explode(':', $user);
        $explodedAddress = explode(':', $address);

        $pdo = new \PDO(
            sprintf(
                'mysql:host=%s;port=%s;dbname=%s',
                $explodedAddress[0],
                ($explodedAddress[1] ?? '3306'),
                $dbName
            ),
            $explodedUser[0],
            $explodedUser[1] ?? '',
            [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION]
        );

        if (!is_null($dbName)) {
            $pdo->query("USE $dbName");
        }

        return $pdo;
    }
1034018
public function deleteDatabase($domainName, $db)
    {
        return $this->getSoapClient(array_merge(array($domainName, $db), array('__method' => 'deleteDatabase')))->deleteDatabase($domainName, $db);
    }
696838
public boolean exitsMongoDbDataBase(String dataBaseName) {
        List<String> dataBaseList = mongoClient.getDatabaseNames();
        return dataBaseList.contains(dataBaseName);
    }
35527
public function exists($name = null)
    {
        if ($name === null) {
            $name = $this->mainname;
        }
        return isset($this->dbs[$name]);
    }
824211
public function setDbName( ?string $dbName ) : PgSQL
   {

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

      $this->_attributes[ 'dbname' ] = $dbName;

      return $this;

   }
124922
public function hasDatabase($name)
    {
        foreach ($this->dbList as $db) {
            if ($db->getName() === $name) {
                return true;
            }
        }

        return false;
    }
70092
public function createDatabase($dbName = null)
    {
        if (is_null($dbName)) {
            $dbName = $this->getDbName();
        }

        $dbName = str_replace('`', '', $dbName);

        Db::exec("CREATE DATABASE IF NOT EXISTS `" . $dbName . "` DEFAULT CHARACTER SET utf8");
    }
536905
final public static function getDbInstance(string $databaseName = '#none'):\PDO
    {
        if (self::$co_instance == null) {
            new self($databaseName);
        }
        return (self::$co_instance);
    }
740452
public function select($database)
	{
		$this->connect();

		if (!$database)
		{
			return false;
		}

		if (!$this->connection->select_db($database))
		{
			throw new ConnectionFailureException('Could not connect to database.');
		}

		return true;
	}