Uses
| Uses | Description |
|---|---|
| wp-includes/wp-db.php: wpdb::__construct() | Connects to the database server and selects a database. |
Load the database class file and instantiate the $wpdb global.
File: wp-includes/load.php
function require_wp_db() {
global $wpdb;
require_once ABSPATH . WPINC . '/wp-db.php';
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) {
require_once WP_CONTENT_DIR . '/db.php';
}
if ( isset( $wpdb ) ) {
return;
}
$dbuser = defined( 'DB_USER' ) ? DB_USER : '';
$dbpassword = defined( 'DB_PASSWORD' ) ? DB_PASSWORD : '';
$dbname = defined( 'DB_NAME' ) ? DB_NAME : '';
$dbhost = defined( 'DB_HOST' ) ? DB_HOST : '';
$wpdb = new wpdb( $dbuser, $dbpassword, $dbname, $dbhost );
} | Version | Description |
|---|---|
| 2.5.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/require_wp_db