Return new wpdb instance
@param $dbuser
@param $dbpassword
@param $dbname
@param $dbhost
@return \wpdb
172085
public function newWpDb($dbuser, $dbpassword, $dbname, $dbhost)
    {
        $wpDbClass = '\wpdb';
        return new $wpDbClass($dbuser, $dbpassword, $dbname, $dbhost);
    }
448453
public function create($host, $port, $user, $password, $dbname)
    {
        $params = [
            ':host' => $host,
            ':port' => $port,
            ':user' => $user,
            ':password' => $password,
            ':dbname' => $dbname
        ];

        $query = 'SELECT sbas_id FROM sbas
                  WHERE host = :host AND port = :port AND `user` = :user AND pwd = :password AND dbname = :dbname';
        $statement = $this->connection->executeQuery($query, $params);

        if ($row = $statement->fetch(\PDO::FETCH_ASSOC)) {
            return $this->find((int) $row['sbas_id']);
        }

        $query = 'INSERT INTO sbas (ord, host, port, dbname, sqlengine, user, pwd)
              SELECT COALESCE(MAX(ord), 0) + 1 AS ord, :host AS host, :port AS port, :dbname AS dbname,
                     "MYSQL" AS sqlengine, :user AS user, :password AS pwd FROM sbas';

        $stmt = $this->connection->prepare($query);
        $stmt->execute($params);

        $stmt->closeCursor();

        return $this->find((int) $this->connection->lastInsertId());

    }
659717
protected CmsUUID createWebusersGroup(CmsSetupDb dbCon) throws SQLException {

        String sql = readQuery(QUERY_CREATE_WEBUSERS_GROUP);
        List<Object> params = new ArrayList<Object>();
        CmsUUID id = new CmsUUID();
        params.add(id.toString());
        params.add(CmsUUID.getNullUUID().toString());
        params.add("allWebusersFromUpgrade6to7");
        params.add(
            "This group was created by the OpenCms Upgrade Wizard to facilitate the handling of former called WebUsers, can be deleted if needed.");
        params.add(new Integer(0));
        params.add("/");
        dbCon.updateSqlStatement(sql, null, params);
        return id;
    }
42072
private function createDsn(string $dbtype, \stdClass $params): string
	{
		$pairs = [];

		if ( ! empty($params->database))
		{
			$pairs[] = implode('=', ['dbname', $params->database]);
		}

		$skip = [
			'name' => 'name',
			'pass' => 'pass',
			'user' => 'user',
			'type' => 'type',
			'prefix' => 'prefix',
			'options' => 'options',
			'database' => 'database',
			'alias' => 'alias'
		];

		foreach($params as $key => $val)
		{
			if (( ! array_key_exists($key, $skip)) &&  ! empty($val))
			{
				$pairs[] = implode('=', [$key, $val]);
			}
		}

		return strtolower($dbtype) . ':' . implode(';', $pairs);
	}
394369
public static function connect($dbType, $dbName, $serverName = '127.0.0.1', $port = '3306', $user = 'root', $password = '', $options = [], $cache = false) {
		self::$db = new Database ( $dbType, $dbName, $serverName, $port, $user, $password, $options, $cache );
		try {
			self::$db->connect ();
		} catch ( \Exception $e ) {
			Logger::error ( "DAO", $e->getMessage () );
			throw new DAOException ( $e->getMessage (), $e->getCode (), $e->getPrevious () );
		}
	}
352043
public static function db(ConfigInterface $dbConfig)
    {
        $key = md5(json_encode($dbConfig->get()));
        if (!isset(self::$dbInstances[$key])) {
            self::$dbInstances[$key] = new DB($dbConfig);
        }

        return self::$dbInstances[$key];
    }
1229403
private static function get_dbuser_dbpass_args( $assoc_args ) {
		$mysql_args = array();
		$dbuser     = Utils\get_flag_value( $assoc_args, 'dbuser' );
		if ( null !== $dbuser ) {
			$mysql_args['dbuser'] = $dbuser;
		}
		$dbpass = Utils\get_flag_value( $assoc_args, 'dbpass' );
		if ( null !== $dbpass ) {
			$mysql_args['dbpass'] = $dbpass;
		}
		return $mysql_args;
	}
69797
protected function createSessionTable($db,$tableName)
	{
		switch($db->getDriverName())
		{
			case 'mysql':
				$blob='LONGBLOB';
				break;
			case 'pgsql':
				$blob='BYTEA';
				break;
			case 'sqlsrv':
			case 'mssql':
			case 'dblib':
				$blob='VARBINARY(MAX)';
				break;
			default:
				$blob='BLOB';
				break;
		}
		$db->createCommand()->createTable($tableName,array(
			'id'=>'CHAR(32) PRIMARY KEY',
			'expire'=>'integer',
			'data'=>$blob,
		));
	}
528629
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
    {
        try {
            return new SQLAnywhereConnection(
                $this->buildDsn(
                    $params['host'] ?? null,
                    $params['port'] ?? null,
                    $params['server'] ?? null,
                    $params['dbname'] ?? null,
                    $username,
                    $password,
                    $driverOptions
                ),
                $params['persistent'] ?? false
            );
        } catch (SQLAnywhereException $e) {
            throw DBALException::driverException($this, $e);
        }
    }
302471
public static DB open(String driver, String url, String user, String password) {
       return new DB(DB.DEFAULT_NAME).open(driver, url, user, password);
    }
543837
public function resolveDatabase($type, $name = null, $user = null, $pass = null, $host = null)
    {
        $database = $this->resolveDatabaseType($type);

        if ($name !== null) {
            $database->name = $name;
        }
        if ($user !== null) {
            $database->user = $user;
        }
        if ($pass !== null) {
            $database->pass = $pass;
        }
        if ($host !== null) {
            $database->host = $host;
        }

        return $database;
    }
1108194
public function checkMysqlConnection($host, $db, $user, $pass)
    {
        $results                        = array();
        $isConnected                    = 0;
        $isDatabaseExists               = 0;
        $isDatabaseCollationNameValid   = 0;
        $isPassCorrect                  = 1;

        if($this->isDomainExists($host)) {
            $isConnected = 1;

            try {
                $dbAdapter = new DbAdapter(array(
                    'driver' =>  'Pdo',
                    'dsn'   =>   'mysql:dbname=INFORMATION_SCHEMA;host='.$host,
                    'username' => $user,
                    'password' => $pass,
                    'driver_options' => array(
                        PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"
                    ),
                ));

                $sql = new Sql($dbAdapter);
                $select = $sql->select();
                $select->from('SCHEMATA');
                $select->where(array('SCHEMA_NAME' => $db));

                $statement = $sql->prepareStatementForSqlObject($select);
                $result = $statement->execute();

                $schema = $result->current();
                if(!empty($schema)) {

                    $isDatabaseExists = 1;

                    if (!empty($schema['DEFAULT_COLLATION_NAME']) && $schema['DEFAULT_COLLATION_NAME'] === 'utf8_general_ci') {
                        $isDatabaseCollationNameValid = 1;
                    }
                }
            }catch(\Exception $e) {
                $isPassCorrect = 0;
            }
        }

        $results = array(
            'isConnected' => $isConnected,
            'isDatabaseExists' => $isDatabaseExists,
            'isMysqlPasswordCorrect' => $isPassCorrect,
            'isDatabaseCollationNameValid' => $isDatabaseCollationNameValid,
        );


        return $results;
    }
1250420
@Override
    protected void createUserDataTable(CmsSetupDb dbCon) throws SQLException {

        System.out.println(new Exception().getStackTrace()[0].toString());
        String createStatement = readQuery(QUERY_CREATE_TABLE_USERDATA_MYSQL);
        Map<String, String> replacer = Collections.singletonMap("${tableEngine}", m_poolData.get("engine"));
        dbCon.updateSqlStatement(createStatement, replacer, null);
    }
213042
public function query(string $sql)
    {
        $this->lastSql = $sql;
        $this->lastStmt = $this->instance->query($sql);
        if(false === $this->lastStmt)
        {
            throw new DbException('sql prepare error: [' . $this->errorCode() . '] ' . $this->errorInfo() . PHP_EOL . 'sql: ' . $sql . PHP_EOL);
        }
        return BeanFactory::newInstance(Statement::class, $this, $this->lastStmt);
    }
403182
public function connect(\stdClass $params): QueryBuilderInterface
	{
		list($dsn, $dbtype, $params, $options) = $this->parseParams($params);

		$dbtype = ucfirst($dbtype);
		$driver = "\\Query\\Drivers\\{$dbtype}\\Driver";

		// Create the database connection
		$db =  ! empty($params->user)
			? new $driver($dsn, $params->user, $params->pass, $options)
			: new $driver($dsn, '', '', $options);

		// Set the table prefix, if it exists
		if (isset($params->prefix))
		{
			$db->setTablePrefix($params->prefix);
		}

		// Create Query Builder object
		$conn = new QueryBuilder($db, new QueryParser($db));


		// Save it for later
		if (isset($params->alias))
		{
			$this->connections[$params->alias] = $conn;
		}
		else
		{
			$this->connections[] = $conn;
		}

		return $conn;
	}
1010798
public function create(string $user_name, string $real_name, string $email, string $password): User
    {
        DB::table('user')->insert([
            'user_name' => $user_name,
            'real_name' => $real_name,
            'email'     => $email,
            'password'  => password_hash($password, PASSWORD_DEFAULT),
        ]);

        $user_id = (int) DB::connection()->getPdo()->lastInsertId();

        return new User($user_id, $user_name, $real_name, $email);
    }
320052
public function mount($host, $port, $user, $password, $dbname)
    {
        $databox = $this->repository->mount($host, $port, $user, $password, $dbname);

        $this->clearCache();

        return $databox;
    }