WordPress at a glance
function is not described

wpdb::__construct() public WP 2.0.8

Connects to the database server and selects a database.

PHP5 style constructor for compatibility with PHP5. Does the actual setting up of the class properties and connection to the database.

It's a method of the class: wpdb{}

No Hooks.

Return

Null. Nothing.

Usage

$wpdb = new wpdb();
$wpdb->__construct( $dbuser, $dbpassword, $dbname, $dbhost );
$dbuser(string) (required)
MySQL database user.
$dbpassword(string) (required)
MySQL database password.
$dbname(string) (required)
MySQL database name.
$dbhost(string) (required)
MySQL database host.

Notes

  • Global. String. $wp_version The WordPress version string.

Changelog

Since 2.0.8 Introduced.

Code of wpdb::__construct() WP 5.5.1

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

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

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

	$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();
}