diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-01-02 16:00:05 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-01-02 16:00:05 +0000 |
commit | 1503e05616c295e6f980134dc341fa1a66dc9672 (patch) | |
tree | b0a7dc356affec0059670603f1cb990da7dbc026 /wp-includes/wp-db.php | |
parent | c65d51fec1d641efd1ec8a44c046cd54d588fe3b (diff) | |
download | wordpress-mu-1503e05616c295e6f980134dc341fa1a66dc9672.tar.gz wordpress-mu-1503e05616c295e6f980134dc341fa1a66dc9672.tar.xz wordpress-mu-1503e05616c295e6f980134dc341fa1a66dc9672.zip |
Merge with WP 2.3.2
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1172 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/wp-db.php')
-rw-r--r-- | wp-includes/wp-db.php | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index ef1070e..adadc31 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -15,11 +15,12 @@ if (!defined('SAVEQUERIES')) class wpdb { - var $show_errors = true; + var $show_errors = false; var $num_queries = 0; var $last_query; var $col_info; var $queries; + var $ready = false; // Our tables var $posts; @@ -58,6 +59,9 @@ class wpdb { function __construct($dbuser, $dbpassword, $dbname, $dbhost) { register_shutdown_function(array(&$this, "__destruct")); + if ( defined('WP_DEBUG') and WP_DEBUG == true ) + $this->show_errors(); + $this->charset = 'utf8'; $this->collete = 'utf8'; @@ -79,8 +83,11 @@ class wpdb { </ul> <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> "); + return; } + $this->ready = true; + if ( !empty($this->charset) && version_compare(mysql_get_server_info(), '4.1.0', '>=') ) $this->query("SET NAMES '$this->charset'"); @@ -97,6 +104,7 @@ class wpdb { */ function select($db, &$dbh) { if (!@mysql_select_db($db, $dbh)) { + $this->ready = false; $this->bail(" <h1>Can’t select database</h1> <p>We were able to connect to the database server (which means your username and password is okay) but not able to select the <code>$db</code> database.</p> @@ -105,6 +113,7 @@ class wpdb { <li>On some systems the name of your database is prefixed with your username, so it would be like username_wordpress. Could that be the problem?</li> </ul> <p>If you don't know how to setup a database you should <strong>contact your host</strong>. If all else fails you may find help at the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p>"); + return; } } @@ -174,12 +183,16 @@ class wpdb { // ================================================================== // Turn error handling on or off.. - function show_errors() { - $this->show_errors = true; + function show_errors( $show = true ) { + $errors = $this->show_errors; + $this->show_errors = $show; + return $errors; } function hide_errors() { + $show = $this->show_errors; $this->show_errors = false; + return $show; } // ================================================================== @@ -231,6 +244,9 @@ class wpdb { // Basic Query - see docs for more detail function query($query) { + if ( ! $this->ready ) + return false; + // filter the query, if filters are available // NOTE: some queries are made before the plugins have been loaded, and thus cannot be filtered with this method if ( function_exists('apply_filters') ) @@ -470,8 +486,13 @@ class wpdb { * @param string $message */ function bail($message) { // Just wraps errors in a nice header and footer - if ( !$this->show_errors ) + if ( !$this->show_errors ) { + if ( class_exists('WP_Error') ) + $this->error = new WP_Error('500', $message); + else + $this->error = $message; return false; + } wp_die($message); } } |