1 | <?php |
---|
2 | class custom_wpdb extends wpdb { |
---|
3 | /** |
---|
4 | * Copy of the db_connect function with definable newlink and client_flags params |
---|
5 | */ |
---|
6 | function db_connect() { |
---|
7 | |
---|
8 | $this->is_mysql = true; |
---|
9 | |
---|
10 | if ( defined( 'DB_NEW_LINK' ) ) |
---|
11 | $this->newlink = DB_NEW_LINK; |
---|
12 | else |
---|
13 | $this->newlink = true; |
---|
14 | |
---|
15 | if ( defined( 'DB_CLIENT_FLAGS' ) ) |
---|
16 | $this->client_flags = DB_CLIENT_FLAGS; |
---|
17 | else |
---|
18 | $this->client_flags = 0; |
---|
19 | |
---|
20 | |
---|
21 | if ( WP_DEBUG ) { |
---|
22 | $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $this->newlink, $this->client_flags ); |
---|
23 | } else { |
---|
24 | $this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $this->newlink, $this->client_flags ); |
---|
25 | } |
---|
26 | |
---|
27 | if ( !$this->dbh ) { |
---|
28 | wp_load_translations_early(); |
---|
29 | $this->bail( sprintf( __( " |
---|
30 | <h1>Error establishing a database connection</h1> |
---|
31 | <p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can't contact the database server at <code>%s</code>. This could mean your host's database server is down.</p> |
---|
32 | <ul> |
---|
33 | <li>Are you sure you have the correct username and password?</li> |
---|
34 | <li>Are you sure that you have typed the correct hostname?</li> |
---|
35 | <li>Are you sure that the database server is running?</li> |
---|
36 | </ul> |
---|
37 | <p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p> |
---|
38 | " ), htmlspecialchars( $this->dbhost, ENT_QUOTES ) ), 'db_connect_fail' ); |
---|
39 | |
---|
40 | return; |
---|
41 | } |
---|
42 | |
---|
43 | $this->set_charset( $this->dbh ); |
---|
44 | |
---|
45 | $this->ready = true; |
---|
46 | |
---|
47 | $this->select( $this->dbname, $this->dbh ); |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | global $wpdb; |
---|
52 | $wpdb = new custom_wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST ); |
---|