gcdb::__construct()

最后更新于:2021-11-26 09:07:10

gcdb::__construct( string$dbuser, string$dbpassword, string$dbname, string$dbhost)

Connects to the database server and selects a database.

参数

$dbuser

(string) (Required) MySQL database user.

$dbpassword

(string) (Required) MySQL database password.

$dbname

(string) (Required) MySQL database name.

$dbhost

(string) (Required) MySQL database host.

源文件

文件: gc-includes/gc-db.php

	public function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) {
		if ( GC_DEBUG && GC_DEBUG_DISPLAY ) {
			$this->show_errors();
		}

		// Use ext/mysqli if it exists unless GC_USE_EXT_MYSQL is defined as true.
		if ( function_exists( 'mysqli_connect' ) ) {
			$this->use_mysqli = true;

			if ( defined( 'GC_USE_EXT_MYSQL' ) ) {
				$this->use_mysqli = ! GC_USE_EXT_MYSQL;
			}
		}

		$this->dbuser     = $dbuser;
		$this->dbpassword = $dbpassword;
		$this->dbname     = $dbname;
		$this->dbhost     = $dbhost;

		// gc-config.php creation will manually connect when ready.
		if ( defined( 'GC_SETUP_CONFIG' ) ) {
			return;
		}

		$this->db_connect();
	}