Opened 17 years ago
Closed 17 years ago
#7215 closed defect (bug) (fixed)
wpdb does not return affected rows using an ALTER query
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 2.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | wp-db, database, alter statement |
Focuses: | Cc: |
Description
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.
Attachments (1)
Change History (2)
Note: See
TracTickets for help on using
tickets.
patch to return affected rows upon using ALTER statement in query