[wp-trac] [WordPress Trac] #7215: wpdb does not return affected rows using an ALTER query

WordPress Trac wp-trac at lists.automattic.com
Tue Jul 1 10:45:41 GMT 2008


#7215: wpdb does not return affected rows using an ALTER query
---------------------+------------------------------------------------------
 Reporter:  BjornW   |       Owner:  anonymous                       
     Type:  defect   |      Status:  new                             
 Priority:  normal   |   Milestone:  2.7                             
Component:  General  |     Version:                                  
 Severity:  normal   |    Keywords:  wp-db, database, alter statement
---------------------+------------------------------------------------------
 As far as I can tell the wpdb class does not return any info after
 performing an ALTER query. After inspection it seems that this is due to a
 missing 'alter' in the regex of this part in the code of /wp-includes/wp-
 db.php:

 {{{
 if ( preg_match("/^\\s*(insert|delete|update|replace) /i",$query) ) {
                         $this->rows_affected =
 mysql_affected_rows($this->dbh);
 }}}

 I added 'alter' to the regex and now you'll get an INT with the number of
 rows affected (incl 0) or FALSE when the query failed. After update the
 code looks like this:

 {{{
 if ( preg_match("/^\\s*(insert|delete|update|replace|alter) /i",$query) )
 {
                         $this->rows_affected =
 mysql_affected_rows($this->dbh);
 }}}

 As far as I can tell this is backwards compatible although I did not
 tested this extensively.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/7215>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list