]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/wp-db.php
Wordpress 3.2-scripts
[autoinstalls/wordpress.git] / wp-includes / wp-db.php
index e9b4e6fb1f29bce5fba2939a505403617f9c2482..0cae3e638e2d626d0d6a55c17e3b77439d215da8 100644 (file)
@@ -39,9 +39,8 @@ define( 'ARRAY_N', 'ARRAY_N' );
  *
  * It is possible to replace this class with your own
  * by setting the $wpdb global variable in wp-content/db.php
- * file with your class. You can name it wpdb also, since
- * this file will not be included, if the other file is
- * available.
+ * file to your class. The wpdb class will still be included,
+ * so you can extend it or simply use your own.
  *
  * @link http://codex.wordpress.org/Function_Reference/wpdb_Class
  *
@@ -461,23 +460,6 @@ class wpdb {
         */
        var $func_call;
 
-       /**
-        * Connects to the database server and selects a database
-        *
-        * PHP4 compatibility layer for calling the PHP5 constructor.
-        *
-        * @uses wpdb::__construct() Passes parameters and returns result
-        * @since 0.71
-        *
-        * @param string $dbuser MySQL database user
-        * @param string $dbpassword MySQL database password
-        * @param string $dbname MySQL database name
-        * @param string $dbhost MySQL database host
-        */
-       function wpdb( $dbuser, $dbpassword, $dbname, $dbhost ) {
-               return $this->__construct( $dbuser, $dbpassword, $dbname, $dbhost );
-       }
-
        /**
         * Connects to the database server and selects a database
         *
@@ -644,6 +626,7 @@ class wpdb {
                if ( is_multisite() ) {
                        if ( null === $blog_id )
                                $blog_id = $this->blogid;
+                       $blog_id = (int) $blog_id;
                        if ( defined( 'MULTISITE' ) && ( 0 == $blog_id || 1 == $blog_id ) )
                                return $this->base_prefix;
                        else
@@ -1030,8 +1013,6 @@ class wpdb {
         * @since 3.0.0
         */
        function db_connect() {
-               global $db_list, $global_db_list;
-
                if ( WP_DEBUG ) {
                        $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, true );
                } else {
@@ -1050,12 +1031,7 @@ class wpdb {
 <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>
 "/*/WP_I18N_DB_CONN_ERROR*/, $this->dbhost ), 'db_connect_fail' );
 
-                       // If show errors is disabled then we need to die anyway as we don't have a working DB connection
-                       // unless we're trying to test the initial connection, in which case setup-config.php will handle.
-                       if ( defined( 'WP_SETUP_CONFIG' ) )
-                               return;
-
-                       die();
+                       return;
                }
 
                $this->set_charset( $this->dbh );
@@ -1107,10 +1083,12 @@ class wpdb {
                        return false;
                }
 
-               if ( preg_match( "/^\\s*(insert|delete|update|replace|alter) /i", $query ) ) {
+               if ( preg_match( '/^\s*(create|alter|truncate|drop) /i', $query ) ) {
+                       $return_val = $this->result;
+               } elseif ( preg_match( '/^\s*(insert|delete|update|replace) /i', $query ) ) {
                        $this->rows_affected = mysql_affected_rows( $this->dbh );
                        // Take note of the insert_id
-                       if ( preg_match( "/^\\s*(insert|replace) /i", $query ) ) {
+                       if ( preg_match( '/^\s*(insert|replace) /i', $query ) ) {
                                $this->insert_id = mysql_insert_id($this->dbh);
                        }
                        // Return number of rows affected
@@ -1388,7 +1366,7 @@ class wpdb {
                        // Return an array of row objects with keys from column 1
                        // (Duplicates are discarded)
                        foreach ( $this->last_result as $row ) {
-                               $key = array_shift( $var_by_ref = get_object_vars( $row ) );
+                               $key = array_shift( get_object_vars( $row ) );
                                if ( ! isset( $new_array[ $key ] ) )
                                        $new_array[ $key ] = $row;
                        }