Ticket #3012: 3012.diff
| File 3012.diff, 2.4 KB (added by , 20 years ago) |
|---|
-
wp-db.php
20 20 var $last_query; 21 21 var $col_info; 22 22 var $queries; 23 var $user; 24 var $password; 25 var $database; 26 var $host; 23 27 24 28 // Our tables 25 29 var $posts; … … 37 41 var $postmeta; 38 42 39 43 // ================================================================== 40 // DB Constructor - connects to the server and selects a database44 // DB Constructor - do nothing: lazy load on execution of query 41 45 42 46 function wpdb($dbuser, $dbpassword, $dbname, $dbhost) { 43 $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword); 47 $this->user = $dbuser; 48 $this->password = $dbpassword; 49 $this->database = $dbname; 50 $this->host = $dbhost; 51 } 52 53 // ================================================================== 54 // connects to the server and selects a database 55 56 function connect() { 57 $this->dbh = @mysql_connect($this->host, $this->user, $this->password); 44 58 if (!$this->dbh) { 45 59 $this->bail(" 46 60 <h1>Error establishing a database connection</h1> 47 <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>$ dbhost</code>. This could mean your host's database server is down.</p>61 <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>$this->host</code>. This could mean your host's database server is down.</p> 48 62 <ul> 49 63 <li>Are you sure you have the correct username and password?</li> 50 64 <li>Are you sure that you have typed the correct hostname?</li> … … 54 68 "); 55 69 } 56 70 57 $this->select( $dbname);71 $this->select(); 58 72 } 59 73 60 74 // ================================================================== 61 75 // Select a DB (if another one needs to be selected) 62 76 63 function select($db) { 77 function select($db = false) { 78 if ( !$db ) 79 $db = $this->database; 64 80 if (!@mysql_select_db($db, $this->dbh)) { 65 81 $this->bail(" 66 82 <h1>Can’t select database</h1> … … 145 161 if (SAVEQUERIES) 146 162 $this->timer_start(); 147 163 164 // Lazy load the database 165 if ( !$this->dbh ) 166 $this->connect(); 167 148 168 $this->result = @mysql_query($query, $this->dbh); 149 169 ++$this->num_queries; 150 170 … … 364 384 } 365 385 366 386 $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); 367 ?> 368 No newline at end of file 387 ?>
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)