wpdb::__construct()publicWP 2.0.8

Connects to the database server and selects a database.

Does the actual setting up of the class properties and connection to the database.

Метод класса: wpdb{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

global $wpdb;
$wpdb->__construct( $dbuser, $dbpassword, $dbname, $dbhost );
$dbuser(строка) (обязательный)
Database user.
$dbpassword(строка) (обязательный)
Database password.
$dbname(строка) (обязательный)
Database name.
$dbhost(строка) (обязательный)
Database host.

Список изменений

С версии 2.0.8 Введена.

Код wpdb::__construct() WP 6.5.2

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

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

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

	$this->db_connect();
}