<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[13314] trunk/wp-includes/wp-db.php: Docs and code convention cleanups.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13314">13314</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-02-22 22:53:54 +0000 (Mon, 22 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Docs and code convention cleanups. see <a href="http://trac.wordpress.org/ticket/11644">#11644</a> props hakre</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludeswpdbphp">trunk/wp-includes/wp-db.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludeswpdbphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/wp-db.php (13313 => 13314)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/wp-db.php        2010-02-22 21:59:40 UTC (rev 13313)
+++ trunk/wp-includes/wp-db.php        2010-02-22 22:53:54 UTC (rev 13314)
</span><span class="lines">@@ -12,27 +12,27 @@
</span><span class="cx"> /**
</span><span class="cx">  * @since 0.71
</span><span class="cx">  */
</span><del>-define('EZSQL_VERSION', 'WP1.25');
</del><ins>+define( 'EZSQL_VERSION', 'WP1.25' );
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * @since 0.71
</span><span class="cx">  */
</span><del>-define('OBJECT', 'OBJECT', true);
</del><ins>+define( 'OBJECT', 'OBJECT', true );
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * @since {@internal Version Unknown}}
</span><span class="cx">  */
</span><del>-define('OBJECT_K', 'OBJECT_K', false);
</del><ins>+define( 'OBJECT_K', 'OBJECT_K', false );
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * @since 0.71
</span><span class="cx">  */
</span><del>-define('ARRAY_A', 'ARRAY_A', false);
</del><ins>+define( 'ARRAY_A', 'ARRAY_A', false );
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * @since 0.71
</span><span class="cx">  */
</span><del>-define('ARRAY_N', 'ARRAY_N', false);
</del><ins>+define( 'ARRAY_N', 'ARRAY_N', false );
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * WordPress Database Access Abstraction Object
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx">          * Whether to suppress errors during the DB bootstrapping.
</span><span class="cx">          *
</span><span class="cx">          * @access private
</span><del>-         * @since {@internal Version Unknown}}
</del><ins>+         * @since 2.5
</ins><span class="cx">          * @var bool
</span><span class="cx">          */
</span><span class="cx">         var $suppress_errors = false;
</span><span class="lines">@@ -73,7 +73,9 @@
</span><span class="cx">         /**
</span><span class="cx">          * The last error during query.
</span><span class="cx">          *
</span><del>-         * @since {@internal Version Unknown}}
</del><ins>+         * @see get_last_error()
+         * @since 2.5
+         * @access private
</ins><span class="cx">          * @var string
</span><span class="cx">          */
</span><span class="cx">         var $last_error = '';
</span><span class="lines">@@ -88,6 +90,22 @@
</span><span class="cx">         var $num_queries = 0;
</span><span class="cx"> 
</span><span class="cx">         /**
</span><ins>+         * Count of rows returned by previous query
+         *
+         * @since 1.2
+         * @var int
+         */
+        var $num_rows = 0; 
+
+        /**
+         * Count of affected rows by previous query
+         *
+         * @since 0.71
+         * @var int
+         */
+        var $rows_affected = 0;
+
+        /**
</ins><span class="cx">          * Saved result of the last query made
</span><span class="cx">          *
</span><span class="cx">          * @since 1.2.0
</span><span class="lines">@@ -97,6 +115,14 @@
</span><span class="cx">         var $last_query;
</span><span class="cx"> 
</span><span class="cx">         /**
</span><ins>+         * Results of the last query made
+         *
+         * @since {@internal Version Unknown}}
+         * @var mixed
+         */
+        var $last_result;
+
+        /**
</ins><span class="cx">          * Saved info on the table column
</span><span class="cx">          *
</span><span class="cx">          * @since 1.2.0
</span><span class="lines">@@ -135,7 +161,21 @@
</span><span class="cx">          * @var bool
</span><span class="cx">          */
</span><span class="cx">         var $ready = false;
</span><ins>+
+        /**
+         * {@internal Missing Description}}
+         *
+         * @since 3.0.0
+         * @var int
+         */
</ins><span class="cx">         var $blogid = 0;
</span><ins>+
+        /**
+         * {@internal Missing Description}}
+         *
+         * @since 3.0.0
+         * @var int
+         */
</ins><span class="cx">         var $siteid = 0;
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -251,6 +291,7 @@
</span><span class="cx">         /**
</span><span class="cx">          * List of deprecated WordPress tables
</span><span class="cx">          *
</span><ins>+         * @deprecated
</ins><span class="cx">          * @since 2.9.0
</span><span class="cx">          * @access private
</span><span class="cx">          * @see wpdb::tables()
</span><span class="lines">@@ -343,10 +384,10 @@
</span><span class="cx">         var $global_tables = array( 'users', 'usermeta' );
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Format specifiers for DB columns. Columns not listed here default to %s. Initialized in wp-settings.php.
</del><ins>+         * Format specifiers for DB columns. Columns not listed here default to %s. Initialized during WP load.
+         * 
+         * Keys are column names, values are format types: 'ID' =&gt; '%d'
</ins><span class="cx">          *
</span><del>-         * Keys are colmn names, values are format types: 'ID' =&gt; '%d'
-         *
</del><span class="cx">          * @since 2.8.0
</span><span class="cx">          * @see wpdb:prepare()
</span><span class="cx">          * @see wpdb:insert()
</span><span class="lines">@@ -406,10 +447,10 @@
</span><span class="cx">          * @param string $dbname MySQL database name
</span><span class="cx">          * @param string $dbhost MySQL database host
</span><span class="cx">          */
</span><del>-        function wpdb($dbuser, $dbpassword, $dbname, $dbhost) {
</del><ins>+        function wpdb( $dbuser, $dbpassword, $dbname, $dbhost ) {
</ins><span class="cx">                 if( defined( 'WP_USE_MULTIPLE_DB' ) &amp;&amp; WP_USE_MULTIPLE_DB )
</span><span class="cx">                         $this-&gt;db_connect();
</span><del>-                return $this-&gt;__construct($dbuser, $dbpassword, $dbname, $dbhost);
</del><ins>+                return $this-&gt;__construct( $dbuser, $dbpassword, $dbname, $dbhost );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -426,8 +467,8 @@
</span><span class="cx">          * @param string $dbname MySQL database name
</span><span class="cx">          * @param string $dbhost MySQL database host
</span><span class="cx">          */
</span><del>-        function __construct($dbuser, $dbpassword, $dbname, $dbhost) {
-                register_shutdown_function(array(&amp;$this, &quot;__destruct&quot;));
</del><ins>+        function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) {
+                register_shutdown_function( array( &amp;$this, '__destruct' ) );
</ins><span class="cx"> 
</span><span class="cx">                 if ( WP_DEBUG )
</span><span class="cx">                         $this-&gt;show_errors();
</span><span class="lines">@@ -442,14 +483,14 @@
</span><span class="cx">                         $this-&gt;collate = DB_COLLATE;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                if ( defined('DB_CHARSET') )
</del><ins>+                if ( defined( 'DB_CHARSET' ) )
</ins><span class="cx">                         $this-&gt;charset = DB_CHARSET;
</span><span class="cx"> 
</span><span class="cx">                 $this-&gt;dbuser = $dbuser;
</span><span class="cx"> 
</span><del>-                $this-&gt;dbh = @mysql_connect($dbhost, $dbuser, $dbpassword, true);
-                if (!$this-&gt;dbh) {
-                        $this-&gt;bail(sprintf(/*WP_I18N_DB_CONN_ERROR*/&quot;
</del><ins>+                $this-&gt;dbh = @mysql_connect( $dbhost, $dbuser, $dbpassword, true );
+                if ( !$this-&gt;dbh ) {
+                        $this-&gt;bail( sprintf( /*WP_I18N_DB_CONN_ERROR*/&quot;
</ins><span class="cx"> &lt;h1&gt;Error establishing a database connection&lt;/h1&gt;
</span><span class="cx"> &lt;p&gt;This either means that the username and password information in your &lt;code&gt;wp-config.php&lt;/code&gt; file is incorrect or we can't contact the database server at &lt;code&gt;%s&lt;/code&gt;. This could mean your host's database server is down.&lt;/p&gt;
</span><span class="cx"> &lt;ul&gt;
</span><span class="lines">@@ -458,33 +499,32 @@
</span><span class="cx">         &lt;li&gt;Are you sure that the database server is running?&lt;/li&gt;
</span><span class="cx"> &lt;/ul&gt;
</span><span class="cx"> &lt;p&gt;If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the &lt;a href='http://wordpress.org/support/'&gt;WordPress Support Forums&lt;/a&gt;.&lt;/p&gt;
</span><del>-&quot;/*/WP_I18N_DB_CONN_ERROR*/, $dbhost), 'db_connect_fail');
</del><ins>+&quot;/*/WP_I18N_DB_CONN_ERROR*/, $dbhost ), 'db_connect_fail' );
</ins><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 $this-&gt;ready = true;
</span><span class="cx"> 
</span><del>-                if ( $this-&gt;has_cap( 'collation' ) &amp;&amp; !empty($this-&gt;charset) ) {
-                        if ( function_exists('mysql_set_charset') ) {
-                                mysql_set_charset($this-&gt;charset, $this-&gt;dbh);
</del><ins>+                if ( $this-&gt;has_cap( 'collation' ) &amp;&amp; !empty( $this-&gt;charset ) ) {
+                        if ( function_exists( 'mysql_set_charset' ) ) {
+                                mysql_set_charset( $this-&gt;charset, $this-&gt;dbh );
</ins><span class="cx">                                 $this-&gt;real_escape = true;
</span><span class="cx">                         } else {
</span><del>-                                $collation_query = &quot;SET NAMES '{$this-&gt;charset}'&quot;;
-                                if ( !empty($this-&gt;collate) )
-                                        $collation_query .= &quot; COLLATE '{$this-&gt;collate}'&quot;;
-                                $this-&gt;query($collation_query);
</del><ins>+                                $query = $this-&gt;prepare( 'SET NAMES %s', $this-&gt;charset );
+                                if ( ! empty( $this-&gt;collate ) )
+                                        $query .= $this-&gt;prepare( ' COLLATE %s', $this-&gt;collate );
+                                $this-&gt;query( $query );
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                $this-&gt;select($dbname, $this-&gt;dbh);
</del><ins>+                $this-&gt;select( $dbname, $this-&gt;dbh );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="cx">          * PHP5 style destructor and will run when database object is destroyed.
</span><span class="cx">          *
</span><span class="cx">          * @since 2.0.8
</span><del>-         *
-         * @return bool Always true
</del><ins>+         * @return bool true
</ins><span class="cx">          */
</span><span class="cx">         function __destruct() {
</span><span class="cx">                 return true;
</span><span class="lines">@@ -503,13 +543,10 @@
</span><span class="cx">          */
</span><span class="cx">         function set_prefix( $prefix ) {
</span><span class="cx"> 
</span><del>-                if ( preg_match('|[^a-z0-9_]|i', $prefix) )
</del><ins>+                if ( preg_match( '|[^a-z0-9_]|i', $prefix ) )
</ins><span class="cx">                         return new WP_Error('invalid_db_prefix', /*WP_I18N_DB_BAD_PREFIX*/'Invalid database prefix'/*/WP_I18N_DB_BAD_PREFIX*/);
</span><span class="cx"> 
</span><del>-                if ( is_multisite() )
-                        $old_prefix = '';
-                else
-                        $old_prefix = $prefix;
</del><ins>+                $old_prefix = is_multisite() ? '' : $prefix;
</ins><span class="cx"> 
</span><span class="cx">                 if ( isset( $this-&gt;base_prefix ) )
</span><span class="cx">                         $old_prefix = $this-&gt;base_prefix;
</span><span class="lines">@@ -517,7 +554,7 @@
</span><span class="cx">                 foreach ( $this-&gt;tables( 'global' ) as $table )
</span><span class="cx">                         $this-&gt;$table = $prefix . $table;
</span><span class="cx"> 
</span><del>-                if ( defined('VHOST') &amp;&amp; empty( $this-&gt;blogid ) )
</del><ins>+                if ( defined( 'VHOST' ) &amp;&amp; empty( $this-&gt;blogid ) )
</ins><span class="cx">                         return $old_prefix;
</span><span class="cx"> 
</span><span class="cx">                 $this-&gt;prefix = $this-&gt;get_blog_prefix( $this-&gt;blogid );
</span><span class="lines">@@ -528,20 +565,29 @@
</span><span class="cx">                 foreach ( (array) $this-&gt;tables( 'old' ) as $table )
</span><span class="cx">                         $this-&gt;$table = $this-&gt;prefix . $table;
</span><span class="cx"> 
</span><del>-                if ( defined('CUSTOM_USER_TABLE') )
</del><ins>+                if ( defined( 'CUSTOM_USER_TABLE' ) )
</ins><span class="cx">                         $this-&gt;users = CUSTOM_USER_TABLE;
</span><span class="cx"> 
</span><del>-                if ( defined('CUSTOM_USER_META_TABLE') )
</del><ins>+                if ( defined( 'CUSTOM_USER_META_TABLE' ) )
</ins><span class="cx">                         $this-&gt;usermeta = CUSTOM_USER_META_TABLE;
</span><span class="cx"> 
</span><span class="cx">                 return $old_prefix;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function set_blog_id($blog_id, $site_id = '') {
-                if ( !empty($site_id) )
</del><ins>+        /**
+         * Sets blog id.
+         *
+         * @since 3.0.0
+         * @access public
+         * @param string $blog_id
+         * @param string $site_id. Optional.
+         * @return string previous blog id
+         */        
+        function set_blog_id( $blog_id, $site_id = '' ) {
+                if ( ! empty( $site_id ) )
</ins><span class="cx">                         $this-&gt;siteid = $site_id;
</span><span class="cx"> 
</span><del>-                $old_blog_id = $this-&gt;blogid;
</del><ins>+                $old_blog_id  = $this-&gt;blogid;
</ins><span class="cx">                 $this-&gt;blogid = $blog_id;
</span><span class="cx"> 
</span><span class="cx">                 $this-&gt;prefix = $this-&gt;get_blog_prefix( $this-&gt;blogid );
</span><span class="lines">@@ -555,7 +601,15 @@
</span><span class="cx">                 return $old_blog_id;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function get_blog_prefix( $blog_id = '' ) {
</del><ins>+        /**
+         * Gets blog prefix.
+         *
+         * @uses is_multisite()
+         * @since 3.0.0
+         * @param int $blog_id. Optional.
+         * @return string Blog prefix.
+         */
+        function get_blog_prefix( $blog_id = 0 ) {
</ins><span class="cx">                 if ( is_multisite() &amp;&amp; $blog_id ) {
</span><span class="cx">                         if ( defined('MULTISITE') &amp;&amp; ( $blog_id == 0 || $blog_id == 1 ) )
</span><span class="cx">                                 return $this-&gt;base_prefix;
</span><span class="lines">@@ -620,10 +674,10 @@
</span><span class="cx">          * @param string $db MySQL database name
</span><span class="cx">          * @return null Always null.
</span><span class="cx">          */
</span><del>-        function select($db, &amp;$dbh) {
-                if (!@mysql_select_db($db, $dbh)) {
</del><ins>+        function select( $db, &amp;$dbh ) {
+                if ( !@mysql_select_db( $db, $dbh ) ) {
</ins><span class="cx">                         $this-&gt;ready = false;
</span><del>-                        $this-&gt;bail(sprintf(/*WP_I18N_DB_SELECT_DB*/'
</del><ins>+                        $this-&gt;bail( sprintf( /*WP_I18N_DB_SELECT_DB*/'
</ins><span class="cx"> &lt;h1&gt;Can&amp;#8217;t select database&lt;/h1&gt;
</span><span class="cx"> &lt;p&gt;We were able to connect to the database server (which means your username and password is okay) but not able to select the &lt;code&gt;%1$s&lt;/code&gt; database.&lt;/p&gt;
</span><span class="cx"> &lt;ul&gt;
</span><span class="lines">@@ -631,24 +685,55 @@
</span><span class="cx"> &lt;li&gt;Does the user &lt;code&gt;%2$s&lt;/code&gt; have permission to use the &lt;code&gt;%1$s&lt;/code&gt; database?&lt;/li&gt;
</span><span class="cx"> &lt;li&gt;On some systems the name of your database is prefixed with your username, so it would be like &lt;code&gt;username_%1$s&lt;/code&gt;. Could that be the problem?&lt;/li&gt;
</span><span class="cx"> &lt;/ul&gt;
</span><del>-&lt;p&gt;If you don\'t know how to setup a database you should &lt;strong&gt;contact your host&lt;/strong&gt;. If all else fails you may find help at the &lt;a href=&quot;http://wordpress.org/support/&quot;&gt;WordPress Support Forums&lt;/a&gt;.&lt;/p&gt;'/*/WP_I18N_DB_SELECT_DB*/, $db, $this-&gt;dbuser), 'db_select_fail');
</del><ins>+&lt;p&gt;If you don\'t know how to setup a database you should &lt;strong&gt;contact your host&lt;/strong&gt;. If all else fails you may find help at the &lt;a href=&quot;http://wordpress.org/support/&quot;&gt;WordPress Support Forums&lt;/a&gt;.&lt;/p&gt;'/*/WP_I18N_DB_SELECT_DB*/, $db, $this-&gt;dbuser ), 'db_select_fail' );
</ins><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function _weak_escape($string) {
-                return addslashes($string);
</del><ins>+        /**
+         * Weak escape
+         *
+         * @see addslashes()
+         * @since  unknown
+         * @access private
+         *
+         * @param  string $string
+         * @return string
+         */
+        function _weak_escape( $string ) {
+                return addslashes( $string );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function _real_escape($string) {
</del><ins>+        /**
+         * Real escape
+         *
+         * @see mysql_real_escape_string()
+         * @see addslashes()
+         * @since 2.8
+         * @access private
+         *
+         * @param  string $string to escape
+         * @return string escaped
+         */
+        function _real_escape( $string ) {
</ins><span class="cx">                 if ( $this-&gt;dbh &amp;&amp; $this-&gt;real_escape )
</span><span class="cx">                         return mysql_real_escape_string( $string, $this-&gt;dbh );
</span><span class="cx">                 else
</span><span class="cx">                         return addslashes( $string );
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function _escape($data) {
-                if ( is_array($data) ) {
</del><ins>+        /**
+         * Escape data.
+         *
+         * @see esc_sql()
+         * @since  2.8
+         * @access private
+         *
+         * @param  string|array $data
+         * @return string|array escaped
+         */
+        function _escape( $data ) {
+                if ( is_array( $data ) ) {
</ins><span class="cx">                         foreach ( (array) $data as $k =&gt; $v ) {
</span><span class="cx">                                 if ( is_array($v) )
</span><span class="cx">                                         $data[$k] = $this-&gt;_escape( $v );
</span><span class="lines">@@ -667,13 +752,13 @@
</span><span class="cx">          *
</span><span class="cx">          * @since 0.71
</span><span class="cx">          *
</span><del>-         * @param string|array $data
-         * @return string query safe string
</del><ins>+         * @param  string|array $data to escape
+         * @return string|array escaped as query safe string
</ins><span class="cx">          */
</span><del>-        function escape($data) {
-                if ( is_array($data) ) {
</del><ins>+        function escape( $data ) {
+                if ( is_array( $data ) ) {
</ins><span class="cx">                         foreach ( (array) $data as $k =&gt; $v ) {
</span><del>-                                if ( is_array($v) )
</del><ins>+                                if ( is_array( $v ) )
</ins><span class="cx">                                         $data[$k] = $this-&gt;escape( $v );
</span><span class="cx">                                 else
</span><span class="cx">                                         $data[$k] = $this-&gt;_weak_escape( $v );
</span><span class="lines">@@ -690,15 +775,25 @@
</span><span class="cx">          *
</span><span class="cx">          * @since 2.3.0
</span><span class="cx">          *
</span><del>-         * @param string $s
</del><ins>+         * @param  string $string to escape
+         * @return void
</ins><span class="cx">          */
</span><del>-        function escape_by_ref(&amp;$string) {
</del><ins>+        function escape_by_ref( &amp;$string ) {
</ins><span class="cx">                 $string = $this-&gt;_real_escape( $string );
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="cx">          * Prepares a SQL query for safe execution.  Uses sprintf()-like syntax.
</span><span class="cx">          *
</span><ins>+         * The following directives can be used in the query format string: 
+         *   %d (decimal number)  
+         *   %s (string)
+         *   %% (literal percentage sign - no argument needed) 
+         *
+         * Both %d and %s are to be left unquoted in the query string and   
+         * they need an argument passed for them. Literals (%) as parts of
+         * the query must be properly written as %%.
+         *
</ins><span class="cx">          * This function only supports a small subset of the sprintf syntax; it only supports %d (decimal number), %s (string).
</span><span class="cx">          * Does not support sign, padding, alignment, width or precision specifiers.
</span><span class="cx">          * Does not support argument numbering/swapping.
</span><span class="lines">@@ -715,23 +810,27 @@
</span><span class="cx">          * @since 2.3.0
</span><span class="cx">          *
</span><span class="cx">          * @param string $query Query statement with sprintf()-like placeholders
</span><del>-         * @param array|mixed $args The array of variables to substitute into the query's placeholders if being called like {@link http://php.net/vsprintf vsprintf()}, or the first variable to substitute into the query's placeholders if being called like {@link http://php.net/sprintf sprintf()}.
-         * @param mixed $args,... further variables to substitute into the query's placeholders if being called like {@link http://php.net/sprintf sprintf()}.
-         * @return null|string Sanitized query string
</del><ins>+         * @param array|mixed $args The array of variables to substitute into the query's placeholders if being called like
+         *         {@link http://php.net/vsprintf vsprintf()}, or the first variable to substitute into the query's placeholders if
+         *         being called like {@link http://php.net/sprintf sprintf()}.
+         * @param mixed $args,... further variables to substitute into the query's placeholders if being called like
+         *         {@link http://php.net/sprintf sprintf()}.
+         * @return null|false|string Sanitized query string, null if there is no query, false if there is an error and string
+         *         if there was something to prepare
</ins><span class="cx">          */
</span><del>-        function prepare($query = null) { // ( $query, *$args )
</del><ins>+        function prepare( $query = null ) { // ( $query, *$args )
</ins><span class="cx">                 if ( is_null( $query ) )
</span><span class="cx">                         return;
</span><span class="cx">                 $args = func_get_args();
</span><del>-                array_shift($args);
</del><ins>+                array_shift( $args );
</ins><span class="cx">                 // If args were passed as an array (as in vsprintf), move them up
</span><del>-                if ( isset($args[0]) &amp;&amp; is_array($args[0]) )
</del><ins>+                if ( isset( $args[0] ) &amp;&amp; is_array($args[0]) )
</ins><span class="cx">                         $args = $args[0];
</span><del>-                $query = str_replace(&quot;'%s'&quot;, '%s', $query); // in case someone mistakenly already singlequoted it
-                $query = str_replace('&quot;%s&quot;', '%s', $query); // doublequote unquoting
-                $query = str_replace('%s', &quot;'%s'&quot;, $query); // quote the strings
-                array_walk($args, array(&amp;$this, 'escape_by_ref'));
-                return @vsprintf($query, $args);
</del><ins>+                $query = str_replace( &quot;'%s'&quot;, '%s', $query ); // in case someone mistakenly already singlequoted it
+                $query = str_replace( '&quot;%s&quot;', '%s', $query ); // doublequote unquoting
+                $query = str_replace( '%s', &quot;'%s'&quot;, $query ); // quote the strings
+                array_walk( $args, array( &amp;$this, 'escape_by_ref' ) );
+                return @vsprintf( $query, $args );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -743,11 +842,12 @@
</span><span class="cx">          * @param string $str The error to display
</span><span class="cx">          * @return bool False if the showing of errors is disabled.
</span><span class="cx">          */
</span><del>-        function print_error($str = '') {
</del><ins>+        function print_error( $str = '' ) {
</ins><span class="cx">                 global $EZSQL_ERROR;
</span><span class="cx"> 
</span><del>-                if (!$str) $str = mysql_error($this-&gt;dbh);
-                $EZSQL_ERROR[] = array ('query' =&gt; $this-&gt;last_query, 'error_str' =&gt; $str);
</del><ins>+                if ( !$str )
+                        $str = mysql_error( $this-&gt;dbh );
+                $EZSQL_ERROR[] = array( 'query' =&gt; $this-&gt;last_query, 'error_str' =&gt; $str );
</ins><span class="cx"> 
</span><span class="cx">                 if ( $this-&gt;suppress_errors )
</span><span class="cx">                         return false;
</span><span class="lines">@@ -780,8 +880,8 @@
</span><span class="cx">                         if ( defined( 'DIEONDBERROR' ) )
</span><span class="cx">                                 die( $msg );
</span><span class="cx">                 } else {
</span><del>-                        $str = htmlspecialchars($str, ENT_QUOTES);
-                        $query = htmlspecialchars($this-&gt;last_query, ENT_QUOTES);
</del><ins>+                        $str   = htmlspecialchars( $str, ENT_QUOTES );
+                        $query = htmlspecialchars( $this-&gt;last_query, ENT_QUOTES );
</ins><span class="cx"> 
</span><span class="cx">                         print &quot;&lt;div id='error'&gt;
</span><span class="cx">                         &lt;p class='wpdberror'&gt;&lt;strong&gt;WordPress database error:&lt;/strong&gt; [$str]&lt;br /&gt;
</span><span class="lines">@@ -799,6 +899,7 @@
</span><span class="cx">          * errors.
</span><span class="cx">          *
</span><span class="cx">          * @since 0.71
</span><ins>+         * @see wpdb::hide_errors()
</ins><span class="cx">          *
</span><span class="cx">          * @param bool $show Whether to show or hide errors
</span><span class="cx">          * @return bool Old value for showing errors.
</span><span class="lines">@@ -812,7 +913,10 @@
</span><span class="cx">         /**
</span><span class="cx">          * Disables showing of database errors.
</span><span class="cx">          *
</span><ins>+         * By default database errors are not shown.
+         *
</ins><span class="cx">          * @since 0.71
</span><ins>+         * @see wpdb::show_errors()
</ins><span class="cx">          *
</span><span class="cx">          * @return bool Whether showing of errors was active or not
</span><span class="cx">          */
</span><span class="lines">@@ -825,12 +929,17 @@
</span><span class="cx">         /**
</span><span class="cx">          * Whether to suppress database errors.
</span><span class="cx">          *
</span><del>-         * @param unknown_type $suppress
-         * @return unknown
</del><ins>+         * By default database errors are suppressed, with a simple
+         * call to this function they can be enabled.
+         *
+         * @since 2.5
+         * @see wpdb::hide_errors()
+         * @param bool $suppress Optional. New value. Defaults to true.
+         * @return bool Old value
</ins><span class="cx">          */
</span><span class="cx">         function suppress_errors( $suppress = true ) {
</span><span class="cx">                 $errors = $this-&gt;suppress_errors;
</span><del>-                $this-&gt;suppress_errors = $suppress;
</del><ins>+                $this-&gt;suppress_errors = (bool) $suppress;
</ins><span class="cx">                 return $errors;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -838,16 +947,17 @@
</span><span class="cx">          * Kill cached query results.
</span><span class="cx">          *
</span><span class="cx">          * @since 0.71
</span><ins>+         * @return void
</ins><span class="cx">          */
</span><span class="cx">         function flush() {
</span><span class="cx">                 $this-&gt;last_result = array();
</span><del>-                $this-&gt;col_info = null;
-                $this-&gt;last_query = null;
</del><ins>+                $this-&gt;col_info    = null;
+                $this-&gt;last_query  = null;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function db_connect( $query = &quot;SELECT&quot; ) {
</span><span class="cx">                 global $db_list, $global_db_list;
</span><del>-                if ( is_array( $db_list ) == false )
</del><ins>+                if ( ! is_array( $db_list ) )
</ins><span class="cx">                         return true;
</span><span class="cx"> 
</span><span class="cx">                 if ( $this-&gt;blogs != '' &amp;&amp; preg_match(&quot;/(&quot; . $this-&gt;blogs . &quot;|&quot; . $this-&gt;users . &quot;|&quot; . $this-&gt;usermeta . &quot;|&quot; . $this-&gt;site . &quot;|&quot; . $this-&gt;sitemeta . &quot;|&quot; . $this-&gt;sitecategories . &quot;)/i&quot;,$query) ) {
</span><span class="lines">@@ -867,7 +977,7 @@
</span><span class="cx">                 $dbhname = &quot;dbh&quot; . $action;
</span><span class="cx">                 $this-&gt;$dbhname = @mysql_connect( $details[ 'db_host' ], $details[ 'db_user' ], $details[ 'db_password' ] );
</span><span class="cx">                 if (!$this-&gt;$dbhname ) {
</span><del>-                        $this-&gt;bail(&quot;
</del><ins>+                        $this-&gt;bail(/*WP_I18N_DB_CONNECT_DB*/&quot;
</ins><span class="cx"> &lt;h1&gt;Error establishing a database connection&lt;/h1&gt;
</span><span class="cx"> &lt;p&gt;This either means that the username and password information in your &lt;code&gt;wp-config.php&lt;/code&gt; file is incorrect or we can't contact the database server at &lt;code&gt;{$details['db_host']}&lt;/code&gt;. This could mean your host's database server is down.&lt;/p&gt;
</span><span class="cx"> &lt;ul&gt;
</span><span class="lines">@@ -876,7 +986,7 @@
</span><span class="cx">         &lt;li&gt;Are you sure that the database server is running?&lt;/li&gt;
</span><span class="cx"> &lt;/ul&gt;
</span><span class="cx"> &lt;p&gt;If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the &lt;a href='http://wordpress.org/support/'&gt;WordPress Support Forums&lt;/a&gt;.&lt;/p&gt;
</span><del>-&quot;);
</del><ins>+&quot;/*/WP_I18N_DB_CONNECT_DB*/);
</ins><span class="cx">                 }
</span><span class="cx">                 $this-&gt;select( $details[ 'db_name' ], $this-&gt;$dbhname );
</span><span class="cx">         }
</span><span class="lines">@@ -888,19 +998,19 @@
</span><span class="cx">          *
</span><span class="cx">          * @since 0.71
</span><span class="cx">          *
</span><del>-         * @param string $query
</del><ins>+         * @param string $query Database query
</ins><span class="cx">          * @return int|false Number of rows affected/selected or false on error
</span><span class="cx">          */
</span><del>-        function query($query) {
</del><ins>+        function query( $query ) {
</ins><span class="cx">                 if ( ! $this-&gt;ready )
</span><span class="cx">                         return false;
</span><span class="cx"> 
</span><span class="cx">                 // filter the query, if filters are available
</span><span class="cx">                 // NOTE: some queries are made before the plugins have been loaded, and thus cannot be filtered with this method
</span><del>-                if ( function_exists('apply_filters') )
-                        $query = apply_filters('query', $query);
</del><ins>+                if ( function_exists( 'apply_filters' ) )
+                        $query = apply_filters( 'query', $query );
</ins><span class="cx"> 
</span><del>-                // initialise return
</del><ins>+                // initialize return
</ins><span class="cx">                 $return_val = 0;
</span><span class="cx">                 $this-&gt;flush();
</span><span class="cx"> 
</span><span class="lines">@@ -910,8 +1020,7 @@
</span><span class="cx">                 // Keep track of the last query for debug..
</span><span class="cx">                 $this-&gt;last_query = $query;
</span><span class="cx"> 
</span><del>-                // Perform the query via std mysql_query function..
-                if ( defined('SAVEQUERIES') &amp;&amp; SAVEQUERIES )
</del><ins>+                if ( defined( 'SAVEQUERIES' ) &amp;&amp; SAVEQUERIES )
</ins><span class="cx">                         $this-&gt;timer_start();
</span><span class="cx"> 
</span><span class="cx">                 // use $this-&gt;dbh for read ops, and $this-&gt;dbhwrite for write ops
</span><span class="lines">@@ -939,45 +1048,44 @@
</span><span class="cx">                         $this-&gt;last_db_used = &quot;other/read&quot;;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                $this-&gt;result = @mysql_query($query, $dbh);
</del><ins>+                $this-&gt;result = @mysql_query( $query, $dbh );
</ins><span class="cx">                 ++$this-&gt;num_queries;
</span><span class="cx"> 
</span><span class="cx">                 if ( defined('SAVEQUERIES') &amp;&amp; SAVEQUERIES )
</span><span class="cx">                         $this-&gt;queries[] = array( $query, $this-&gt;timer_stop(), $this-&gt;get_caller() );
</span><span class="cx"> 
</span><span class="cx">                 // If there is an error then take note of it..
</span><del>-                if ( $this-&gt;last_error = mysql_error($dbh) ) {
</del><ins>+                if ( $this-&gt;last_error = mysql_error( $dbh ) ) {
</ins><span class="cx">                         $this-&gt;print_error();
</span><span class="cx">                         return false;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                if ( preg_match(&quot;/^\\s*(insert|delete|update|replace|alter) /i&quot;,$query) ) {
-                        $this-&gt;rows_affected = mysql_affected_rows($dbh);
</del><ins>+                if ( preg_match( &quot;/^\\s*(insert|delete|update|replace|alter) /i&quot;, $query ) ) {
+                        $this-&gt;rows_affected = mysql_affected_rows( $dbh );
</ins><span class="cx">                         // Take note of the insert_id
</span><del>-                        if ( preg_match(&quot;/^\\s*(insert|replace) /i&quot;,$query) ) {
</del><ins>+                        if ( preg_match( &quot;/^\\s*(insert|replace) /i&quot;, $query ) ) {
</ins><span class="cx">                                 $this-&gt;insert_id = mysql_insert_id($dbh);
</span><span class="cx">                         }
</span><span class="cx">                         // Return number of rows affected
</span><span class="cx">                         $return_val = $this-&gt;rows_affected;
</span><span class="cx">                 } else {
</span><span class="cx">                         $i = 0;
</span><del>-                        while ($i &lt; @mysql_num_fields($this-&gt;result)) {
-                                $this-&gt;col_info[$i] = @mysql_fetch_field($this-&gt;result);
</del><ins>+                        while ( $i &lt; @mysql_num_fields( $this-&gt;result ) ) {
+                                $this-&gt;col_info[$i] = @mysql_fetch_field( $this-&gt;result );
</ins><span class="cx">                                 $i++;
</span><span class="cx">                         }
</span><span class="cx">                         $num_rows = 0;
</span><del>-                        while ( $row = @mysql_fetch_object($this-&gt;result) ) {
</del><ins>+                        while ( $row = @mysql_fetch_object( $this-&gt;result ) ) {
</ins><span class="cx">                                 $this-&gt;last_result[$num_rows] = $row;
</span><span class="cx">                                 $num_rows++;
</span><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        @mysql_free_result($this-&gt;result);
</del><ins>+                        @mysql_free_result( $this-&gt;result );
</ins><span class="cx"> 
</span><span class="cx">                         // Log number of rows the query returned
</span><ins>+                        // and return number of rows selected
</ins><span class="cx">                         $this-&gt;num_rows = $num_rows;
</span><del>-
-                        // Return number of rows selected
-                        $return_val = $this-&gt;num_rows;
</del><ins>+                        $return_val     = $num_rows;
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 return $return_val;
</span><span class="lines">@@ -998,21 +1106,21 @@
</span><span class="cx">          * @param array|string $format (optional) An array of formats to be mapped to each of the value in $data.  If string, that format will be used for all of the values in $data.  A format is one of '%d', '%s' (decimal number, string).  If omitted, all values in $data will be treated as strings.
</span><span class="cx">          * @return int|false The number of rows inserted, or false on error.
</span><span class="cx">          */
</span><del>-        function insert($table, $data, $format = null) {
</del><ins>+        function insert( $table, $data, $format = null ) {
</ins><span class="cx">                 $formats = $format = (array) $format;
</span><del>-                $fields = array_keys($data);
</del><ins>+                $fields = array_keys( $data );
</ins><span class="cx">                 $formatted_fields = array();
</span><span class="cx">                 foreach ( $fields as $field ) {
</span><del>-                        if ( !empty($format) )
-                                $form = ( $form = array_shift($formats) ) ? $form : $format[0];
-                        elseif ( isset($this-&gt;field_types[$field]) )
</del><ins>+                        if ( !empty( $format ) )
+                                $form = ( $form = array_shift( $formats ) ) ? $form : $format[0];
+                        elseif ( isset( $this-&gt;field_types[$field] ) )
</ins><span class="cx">                                 $form = $this-&gt;field_types[$field];
</span><span class="cx">                         else
</span><span class="cx">                                 $form = '%s';
</span><span class="cx">                         $formatted_fields[] = $form;
</span><span class="cx">                 }
</span><span class="cx">                 $sql = &quot;INSERT INTO `$table` (`&quot; . implode( '`,`', $fields ) . &quot;`) VALUES ('&quot; . implode( &quot;','&quot;, $formatted_fields ) . &quot;')&quot;;
</span><del>-                return $this-&gt;query( $this-&gt;prepare( $sql, $data) );
</del><ins>+                return $this-&gt;query( $this-&gt;prepare( $sql, $data ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -1033,15 +1141,15 @@
</span><span class="cx">          * @param array|string $format_where (optional) An array of formats to be mapped to each of the values in $where.  If string, that format will be used for all of  the items in $where.  A format is one of '%d', '%s' (decimal number, string).  If omitted, all values in $where will be treated as strings.
</span><span class="cx">          * @return int|false The number of rows updated, or false on error.
</span><span class="cx">          */
</span><del>-        function update($table, $data, $where, $format = null, $where_format = null) {
-                if ( !is_array( $where ) )
</del><ins>+        function update( $table, $data, $where, $format = null, $where_format = null ) {
+                if ( ! is_array( $where ) )
</ins><span class="cx">                         return false;
</span><span class="cx"> 
</span><span class="cx">                 $formats = $format = (array) $format;
</span><span class="cx">                 $bits = $wheres = array();
</span><del>-                foreach ( (array) array_keys($data) as $field ) {
-                        if ( !empty($format) )
-                                $form = ( $form = array_shift($formats) ) ? $form : $format[0];
</del><ins>+                foreach ( (array) array_keys( $data ) as $field ) {
+                        if ( !empty( $format ) )
+                                $form = ( $form = array_shift( $formats ) ) ? $form : $format[0];
</ins><span class="cx">                         elseif ( isset($this-&gt;field_types[$field]) )
</span><span class="cx">                                 $form = $this-&gt;field_types[$field];
</span><span class="cx">                         else
</span><span class="lines">@@ -1050,10 +1158,10 @@
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 $where_formats = $where_format = (array) $where_format;
</span><del>-                foreach ( (array) array_keys($where) as $field ) {
-                        if ( !empty($where_format) )
-                                $form = ( $form = array_shift($where_formats) ) ? $form : $where_format[0];
-                        elseif ( isset($this-&gt;field_types[$field]) )
</del><ins>+                foreach ( (array) array_keys( $where ) as $field ) {
+                        if ( !empty( $where_format ) )
+                                $form = ( $form = array_shift( $where_formats ) ) ? $form : $where_format[0];
+                        elseif ( isset( $this-&gt;field_types[$field] ) )
</ins><span class="cx">                                 $form = $this-&gt;field_types[$field];
</span><span class="cx">                         else
</span><span class="cx">                                 $form = '%s';
</span><span class="lines">@@ -1061,7 +1169,7 @@
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 $sql = &quot;UPDATE `$table` SET &quot; . implode( ', ', $bits ) . ' WHERE ' . implode( ' AND ', $wheres );
</span><del>-                return $this-&gt;query( $this-&gt;prepare( $sql, array_merge(array_values($data), array_values($where))) );
</del><ins>+                return $this-&gt;query( $this-&gt;prepare( $sql, array_merge( array_values( $data ), array_values( $where ) ) ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -1073,23 +1181,23 @@
</span><span class="cx">          *
</span><span class="cx">          * @since 0.71
</span><span class="cx">          *
</span><del>-         * @param string|null $query SQL query.  If null, use the result from the previous query.
</del><ins>+         * @param string|null $query Optional. SQL query. If null (default), uses the result from the previous query.
</ins><span class="cx">          * @param int $x (optional) Column of value to return.  Indexed from 0.
</span><span class="cx">          * @param int $y (optional) Row of value to return.  Indexed from 0.
</span><del>-         * @return string Database query result
</del><ins>+         * @return string|null Database query result, or null on failure
</ins><span class="cx">          */
</span><del>-        function get_var($query=null, $x = 0, $y = 0) {
-                $this-&gt;func_call = &quot;\$db-&gt;get_var(\&quot;$query\&quot;,$x,$y)&quot;;
</del><ins>+        function get_var( $query = null, $x = 0, $y = 0 ) {
+                $this-&gt;func_call = &quot;\$db-&gt;get_var(\&quot;$query\&quot;, $x, $y)&quot;;
</ins><span class="cx">                 if ( $query )
</span><del>-                        $this-&gt;query($query);
</del><ins>+                        $this-&gt;query( $query );
</ins><span class="cx"> 
</span><span class="cx">                 // Extract var out of cached results based x,y vals
</span><span class="cx">                 if ( !empty( $this-&gt;last_result[$y] ) ) {
</span><del>-                        $values = array_values(get_object_vars($this-&gt;last_result[$y]));
</del><ins>+                        $values = array_values( get_object_vars( $this-&gt;last_result[$y] ) );
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 // If there is a value return it else return null
</span><del>-                return (isset($values[$x]) &amp;&amp; $values[$x]!=='') ? $values[$x] : null;
</del><ins>+                return ( isset( $values[$x] ) &amp;&amp; $values[$x] !== '' ) ? $values[$x] : null;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -1102,24 +1210,24 @@
</span><span class="cx">          * @param string|null $query SQL query.
</span><span class="cx">          * @param string $output (optional) one of ARRAY_A | ARRAY_N | OBJECT constants.  Return an associative array (column =&gt; value, ...), a numerically indexed array (0 =&gt; value, ...) or an object ( -&gt;column = value ), respectively.
</span><span class="cx">          * @param int $y (optional) Row to return.  Indexed from 0.
</span><del>-         * @return mixed Database query result in format specifed by $output
</del><ins>+         * @return mixed Database query result in format specifed by $output or null on failure
</ins><span class="cx">          */
</span><del>-        function get_row($query = null, $output = OBJECT, $y = 0) {
</del><ins>+        function get_row( $query = null, $output = OBJECT, $y = 0 ) {
</ins><span class="cx">                 $this-&gt;func_call = &quot;\$db-&gt;get_row(\&quot;$query\&quot;,$output,$y)&quot;;
</span><span class="cx">                 if ( $query )
</span><del>-                        $this-&gt;query($query);
</del><ins>+                        $this-&gt;query( $query );
</ins><span class="cx">                 else
</span><span class="cx">                         return null;
</span><span class="cx"> 
</span><del>-                if ( !isset($this-&gt;last_result[$y]) )
</del><ins>+                if ( !isset( $this-&gt;last_result[$y] ) )
</ins><span class="cx">                         return null;
</span><span class="cx"> 
</span><span class="cx">                 if ( $output == OBJECT ) {
</span><span class="cx">                         return $this-&gt;last_result[$y] ? $this-&gt;last_result[$y] : null;
</span><span class="cx">                 } elseif ( $output == ARRAY_A ) {
</span><del>-                        return $this-&gt;last_result[$y] ? get_object_vars($this-&gt;last_result[$y]) : null;
</del><ins>+                        return $this-&gt;last_result[$y] ? get_object_vars( $this-&gt;last_result[$y] ) : null;
</ins><span class="cx">                 } elseif ( $output == ARRAY_N ) {
</span><del>-                        return $this-&gt;last_result[$y] ? array_values(get_object_vars($this-&gt;last_result[$y])) : null;
</del><ins>+                        return $this-&gt;last_result[$y] ? array_values( get_object_vars( $this-&gt;last_result[$y] ) ) : null;
</ins><span class="cx">                 } else {
</span><span class="cx">                         $this-&gt;print_error(/*WP_I18N_DB_GETROW_ERROR*/&quot; \$db-&gt;get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N&quot;/*/WP_I18N_DB_GETROW_ERROR*/);
</span><span class="cx">                 }
</span><span class="lines">@@ -1134,18 +1242,18 @@
</span><span class="cx">          *
</span><span class="cx">          * @since 0.71
</span><span class="cx">          *
</span><del>-         * @param string|null $query SQL query.  If null, use the result from the previous query.
-         * @param int $x Column to return.  Indexed from 0.
-         * @return array Database query result.  Array indexed from 0 by SQL result row number.
</del><ins>+         * @param string|null $query Optional. SQL query. If null (default), use the result from the previous query.
+         * @param int $x Optional. Column to return. Indexed from 0.
+         * @return array Database query result. Array indexed from 0 by SQL result row number.
</ins><span class="cx">          */
</span><del>-        function get_col($query = null , $x = 0) {
</del><ins>+        function get_col( $query = null , $x = 0 ) {
</ins><span class="cx">                 if ( $query )
</span><del>-                        $this-&gt;query($query);
</del><ins>+                        $this-&gt;query( $query );
</ins><span class="cx"> 
</span><span class="cx">                 $new_array = array();
</span><span class="cx">                 // Extract the column values
</span><del>-                for ( $i=0; $i &lt; count($this-&gt;last_result); $i++ ) {
-                        $new_array[$i] = $this-&gt;get_var(null, $x, $i);
</del><ins>+                for ( $i=0; $i &lt; count( $this-&gt;last_result ); $i++ ) {
+                        $new_array[$i] = $this-&gt;get_var( null, $x, $i );
</ins><span class="cx">                 }
</span><span class="cx">                 return $new_array;
</span><span class="cx">         }
</span><span class="lines">@@ -1161,11 +1269,11 @@
</span><span class="cx">          * @param string $output (optional) ane of ARRAY_A | ARRAY_N | OBJECT | OBJECT_K constants.  With one of the first three, return an array of rows indexed from 0 by SQL result row number.  Each row is an associative array (column =&gt; value, ...), a numerically indexed array (0 =&gt; value, ...), or an object. ( -&gt;column = value ), respectively.  With OBJECT_K, return an associative array of row objects keyed by the value of each row's first column's value.  Duplicate keys are discarded.
</span><span class="cx">          * @return mixed Database query results
</span><span class="cx">          */
</span><del>-        function get_results($query = null, $output = OBJECT) {
</del><ins>+        function get_results( $query = null, $output = OBJECT ) {
</ins><span class="cx">                 $this-&gt;func_call = &quot;\$db-&gt;get_results(\&quot;$query\&quot;, $output)&quot;;
</span><span class="cx"> 
</span><span class="cx">                 if ( $query )
</span><del>-                        $this-&gt;query($query);
</del><ins>+                        $this-&gt;query( $query );
</ins><span class="cx">                 else
</span><span class="cx">                         return null;
</span><span class="cx"> 
</span><span class="lines">@@ -1206,14 +1314,14 @@
</span><span class="cx">          *
</span><span class="cx">          * @since 0.71
</span><span class="cx">          *
</span><del>-         * @param string $info_type one of name, table, def, max_length, not_null, primary_key, multiple_key, unique_key, numeric, blob, type, unsigned, zerofill
-         * @param int $col_offset 0: col name. 1: which table the col's in. 2: col's max length. 3: if the col is numeric. 4: col's type
</del><ins>+         * @param string $info_type Optional. Type one of name, table, def, max_length, not_null, primary_key, multiple_key, unique_key, numeric, blob, type, unsigned, zerofill
+         * @param int $col_offset Optional. 0: col name. 1: which table the col's in. 2: col's max length. 3: if the col is numeric. 4: col's type
</ins><span class="cx">          * @return mixed Column Results
</span><span class="cx">          */
</span><del>-        function get_col_info($info_type = 'name', $col_offset = -1) {
</del><ins>+        function get_col_info( $info_type = 'name', $col_offset = -1 ) {
</ins><span class="cx">                 if ( $this-&gt;col_info ) {
</span><span class="cx">                         if ( $col_offset == -1 ) {
</span><del>-                                $i = 0;
</del><ins>+                                $i         = 0;
</ins><span class="cx">                                 $new_array = array();
</span><span class="cx">                                 foreach( (array) $this-&gt;col_info as $col ) {
</span><span class="cx">                                         $new_array[$i] = $col-&gt;{$info_type};
</span><span class="lines">@@ -1234,8 +1342,7 @@
</span><span class="cx">          * @return true
</span><span class="cx">          */
</span><span class="cx">         function timer_start() {
</span><del>-                $mtime = microtime();
-                $mtime = explode(' ', $mtime);
</del><ins>+                $mtime            = explode( ' ', microtime() );
</ins><span class="cx">                 $this-&gt;time_start = $mtime[1] + $mtime[0];
</span><span class="cx">                 return true;
</span><span class="cx">         }
</span><span class="lines">@@ -1248,9 +1355,8 @@
</span><span class="cx">          * @return int Total time spent on the query, in milliseconds
</span><span class="cx">          */
</span><span class="cx">         function timer_stop() {
</span><del>-                $mtime = microtime();
-                $mtime = explode(' ', $mtime);
-                $time_end = $mtime[1] + $mtime[0];
</del><ins>+                $mtime      = explode( ' ', microtime() );
+                $time_end   = $mtime[1] + $mtime[0];
</ins><span class="cx">                 $time_total = $time_end - $this-&gt;time_start;
</span><span class="cx">                 return $time_total;
</span><span class="cx">         }
</span><span class="lines">@@ -1266,9 +1372,9 @@
</span><span class="cx">          * @param string $error_code (optional) A Computer readable string to identify the error.
</span><span class="cx">          * @return false|void
</span><span class="cx">          */
</span><del>-        function bail($message, $error_code = '500') {
</del><ins>+        function bail( $message, $error_code = '500' ) {
</ins><span class="cx">                 if ( !$this-&gt;show_errors ) {
</span><del>-                        if ( class_exists('WP_Error') )
</del><ins>+                        if ( class_exists( 'WP_Error' ) )
</ins><span class="cx">                                 $this-&gt;error = new WP_Error($error_code, $message);
</span><span class="cx">                         else
</span><span class="cx">                                 $this-&gt;error = $message;
</span><span class="lines">@@ -1282,6 +1388,7 @@
</span><span class="cx">          *
</span><span class="cx">          * @since 2.5.0
</span><span class="cx">          * @uses $wp_version
</span><ins>+         * @uses $required_mysql_version
</ins><span class="cx">          *
</span><span class="cx">          * @return WP_Error
</span><span class="cx">          */
</span><span class="lines">@@ -1289,7 +1396,7 @@
</span><span class="cx">                 global $wp_version, $required_mysql_version;
</span><span class="cx">                 // Make sure the server has the required MySQL version
</span><span class="cx">                 if ( version_compare($this-&gt;db_version(), $required_mysql_version, '&lt;') )
</span><del>-                        return new WP_Error('database_version',sprintf(__('&lt;strong&gt;ERROR&lt;/strong&gt;: WordPress %1$s requires MySQL %2$s or higher'), $wp_version, $required_mysql_version));
</del><ins>+                        return new WP_Error('database_version', sprintf( __( '&lt;strong&gt;ERROR&lt;/strong&gt;: WordPress %1$s requires MySQL %2$s or higher' ), $wp_version, $required_mysql_version ));
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -1306,21 +1413,25 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Generic function to determine if a database supports a particular feature
</del><ins>+         * Determine if a database supports a particular feature
+         *
+         * @since 2.7
+         * @see   wpdb::db_version()
+         *
</ins><span class="cx">          * @param string $db_cap the feature
</span><del>-         * @param false|string|resource $dbh_or_table (not implemented) Which database to test.  False = the currently selected database, string = the database containing the specified table, resource = the database corresponding to the specified mysql resource.
</del><ins>+         * @param false|string|resource $dbh_or_table. Not implemented.
+         *         Which database to test. False = the currently selected database, string = the database containing the specified table, resource = the database corresponding to the specified mysql resource.
</ins><span class="cx">          * @return bool
</span><span class="cx">          */
</span><span class="cx">         function has_cap( $db_cap ) {
</span><span class="cx">                 $version = $this-&gt;db_version();
</span><span class="cx"> 
</span><del>-                switch ( strtolower( $db_cap ) ) :
-                case 'collation' :    // @since 2.5.0
-                case 'group_concat' : // @since 2.7
-                case 'subqueries' :   // @since 2.7
-                        return version_compare($version, '4.1', '&gt;=');
-                        break;
-                endswitch;
</del><ins>+                switch ( strtolower( $db_cap ) ) {
+                        case 'collation' :    // @since 2.5.0
+                        case 'group_concat' : // @since 2.7
+                        case 'subqueries' :   // @since 2.7
+                                return version_compare( $version, '4.1', '&gt;=' );
+                };
</ins><span class="cx"> 
</span><span class="cx">                 return false;
</span><span class="cx">         }
</span><span class="lines">@@ -1355,11 +1466,12 @@
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="cx">          * The database version number
</span><del>-         * @param false|string|resource $dbh_or_table (not implemented) Which database to test.  False = the currently selected database, string = the database containing the specified table, resource = the database corresponding to the specified mysql resource.
</del><ins>+         * @param false|string|resource $dbh_or_table. Not implemented.
+         *         Which database to test. False = the currently selected database, string = the database containing the specified table, resource = the database corresponding to the specified mysql resource.
</ins><span class="cx">          * @return false|string false on failure, version number on success
</span><span class="cx">          */
</span><span class="cx">         function db_version() {
</span><del>-                return preg_replace('/[^0-9.].*/', '', mysql_get_server_info( $this-&gt;dbh ));
</del><ins>+                return preg_replace( '/[^0-9.].*/', '', mysql_get_server_info( $this-&gt;dbh ) );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>