]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/wp-db.php
Wordpress 2.9
[autoinstalls/wordpress.git] / wp-includes / wp-db.php
index a4ff757c8cf7d186fb26ee606fd4a33e17633f8f..d2f79a63995400dfa5f06d6bada4cc1c8f4b5d84 100644 (file)
@@ -208,6 +208,15 @@ class wpdb {
         */
        var $postmeta;
 
         */
        var $postmeta;
 
+       /**
+        * WordPress Comment Metadata table
+        *
+        * @since 2.9
+        * @access public
+        * @var string
+        */
+       var $commentmeta;
+
        /**
         * WordPress User Metadata table
         *
        /**
         * WordPress User Metadata table
         *
@@ -252,7 +261,17 @@ class wpdb {
         * @var array
         */
        var $tables = array('users', 'usermeta', 'posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options',
         * @var array
         */
        var $tables = array('users', 'usermeta', 'posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options',
-                       'postmeta', 'terms', 'term_taxonomy', 'term_relationships');
+                       'postmeta', 'terms', 'term_taxonomy', 'term_relationships', 'commentmeta');
+
+       /**
+        * List of deprecated WordPress tables
+        *
+        * @since 2.9.0
+        * @access private
+        * @var array
+        */
+       var $old_tables = array('categories', 'post2cat', 'link2cat');
+
 
        /**
         * Format specifiers for DB columns. Columns not listed here default to %s.  Initialized in wp-settings.php.
 
        /**
         * Format specifiers for DB columns. Columns not listed here default to %s.  Initialized in wp-settings.php.
@@ -295,6 +314,15 @@ class wpdb {
         */
        var $real_escape = false;
 
         */
        var $real_escape = false;
 
+       /**
+        * Database Username
+        *
+        * @since 2.9.0
+        * @access private
+        * @var string
+        */
+       var $dbuser;
+
        /**
         * Connects to the database server and selects a database
         *
        /**
         * Connects to the database server and selects a database
         *
@@ -329,7 +357,7 @@ class wpdb {
        function __construct($dbuser, $dbpassword, $dbname, $dbhost) {
                register_shutdown_function(array(&$this, "__destruct"));
 
        function __construct($dbuser, $dbpassword, $dbname, $dbhost) {
                register_shutdown_function(array(&$this, "__destruct"));
 
-               if ( defined('WP_DEBUG') and WP_DEBUG == true )
+               if ( WP_DEBUG )
                        $this->show_errors();
 
                if ( defined('DB_CHARSET') )
                        $this->show_errors();
 
                if ( defined('DB_CHARSET') )
@@ -338,6 +366,8 @@ class wpdb {
                if ( defined('DB_COLLATE') )
                        $this->collate = DB_COLLATE;
 
                if ( defined('DB_COLLATE') )
                        $this->collate = DB_COLLATE;
 
+               $this->dbuser = $dbuser;
+
                $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword, true);
                if (!$this->dbh) {
                        $this->bail(sprintf(/*WP_I18N_DB_CONN_ERROR*/"
                $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword, true);
                if (!$this->dbh) {
                        $this->bail(sprintf(/*WP_I18N_DB_CONN_ERROR*/"
@@ -349,23 +379,21 @@ class wpdb {
        <li>Are you sure that the database server is running?</li>
 </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>
        <li>Are you sure that the database server is running?</li>
 </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>
-"/*/WP_I18N_DB_CONN_ERROR*/, $dbhost));
+"/*/WP_I18N_DB_CONN_ERROR*/, $dbhost), 'db_connect_fail');
                        return;
                }
 
                $this->ready = true;
 
                        return;
                }
 
                $this->ready = true;
 
-               if ( $this->has_cap( 'collation' ) ) {
-                       if ( !empty($this->charset) ) {
-                               if ( function_exists('mysql_set_charset') ) {
-                                       mysql_set_charset($this->charset, $this->dbh);
-                                       $this->real_escape = true;
-                               } else {
-                                       $collation_query = "SET NAMES '{$this->charset}'";
-                                       if ( !empty($this->collate) )
-                                               $collation_query .= " COLLATE '{$this->collate}'";
-                                       $this->query($collation_query);
-                               }
+               if ( !empty($this->charset) ) {
+                       if ( function_exists('mysql_set_charset') ) {
+                               mysql_set_charset($this->charset, $this->dbh);
+                               $this->real_escape = true;
+                       } else {
+                               $collation_query = "SET NAMES '{$this->charset}'";
+                               if ( !empty($this->collate) )
+                                       $collation_query .= " COLLATE '{$this->collate}'";
+                               $this->query($collation_query);
                        }
                }
 
                        }
                }
 
@@ -436,7 +464,7 @@ class wpdb {
 <li>Does the user <code>%2$s</code> have permission to use the <code>%1$s</code> database?</li>
 <li>On some systems the name of your database is prefixed with your username, so it would be like <code>username_%1$s</code>. Could that be the problem?</li>
 </ul>
 <li>Does the user <code>%2$s</code> have permission to use the <code>%1$s</code> database?</li>
 <li>On some systems the name of your database is prefixed with your username, so it would be like <code>username_%1$s</code>. 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>'/*/WP_I18N_DB_SELECT_DB*/, $db, DB_USER));
+<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>'/*/WP_I18N_DB_SELECT_DB*/, $db, $this->dbuser), 'db_select_fail');
                        return;
                }
        }
                        return;
                }
        }
@@ -996,13 +1024,14 @@ class wpdb {
         *
         * @since 1.5.0
         *
         *
         * @since 1.5.0
         *
-        * @param string $message
+        * @param string $message The Error message
+        * @param string $error_code (optional) A Computer readable string to identify the error.
         * @return false|void
         */
         * @return false|void
         */
-       function bail($message) {
+       function bail($message, $error_code = '500') {
                if ( !$this->show_errors ) {
                        if ( class_exists('WP_Error') )
                if ( !$this->show_errors ) {
                        if ( class_exists('WP_Error') )
-                               $this->error = new WP_Error('500', $message);
+                               $this->error = new WP_Error($error_code, $message);
                        else
                                $this->error = $message;
                        return false;
                        else
                                $this->error = $message;
                        return false;
@@ -1021,9 +1050,9 @@ class wpdb {
        function check_database_version()
        {
                global $wp_version;
        function check_database_version()
        {
                global $wp_version;
-               // Make sure the server has MySQL 4.0
-               if ( version_compare($this->db_version(), '4.0.0', '<') )
-                       return new WP_Error('database_version',sprintf(__('<strong>ERROR</strong>: WordPress %s requires MySQL 4.0.0 or higher'), $wp_version));
+               // Make sure the server has MySQL 4.1.2
+               if ( version_compare($this->db_version(), '4.1.2', '<') )
+                       return new WP_Error('database_version',sprintf(__('<strong>ERROR</strong>: WordPress %s requires MySQL 4.1.2 or higher'), $wp_version));
        }
 
        /**
        }
 
        /**
@@ -1035,8 +1064,7 @@ class wpdb {
         *
         * @return bool True if collation is supported, false if version does not
         */
         *
         * @return bool True if collation is supported, false if version does not
         */
-       function supports_collation()
-       {
+       function supports_collation() {
                return $this->has_cap( 'collation' );
        }
 
                return $this->has_cap( 'collation' );
        }