[wp-trac] [WordPress Trac] #19467: wpdb does not always set rows_affected or insert_id properties when needed
WordPress Trac
wp-trac at lists.automattic.com
Thu Jun 28 17:57:23 UTC 2012
#19467: wpdb does not always set rows_affected or insert_id properties when needed
------------------------------+------------------
Reporter: GeertDD | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 3.5
Component: Database | Version: 3.3
Severity: minor | Resolution:
Keywords: has-patch commit |
------------------------------+------------------
Changes (by Bellfalasch):
* cc: Bellfalasch (added)
Comment:
I'm not that all familiar with WP, but I am with MySQL. So sorry if I'm
all off here =/
An UPDATE which has an valid target with it's WHERE-statement, but doesn't
change any data in a table will return rows_affected = 0. An error would
produce rows_affected = -1.
If we have the table `test` with columns `id` and `awesome` set to 1 and
'Hi!' respectivly.
First we do this:
UPDATE `test` SET `awesome` = 'Bye!' WHERE id = 1
rows_affected = 1
Right after that we run the same SQL and get 0 affected rows since no
changes was made in the db.
UPDATE `test` SET `awesome` = 'Bye!' WHERE id = 1
rows_affected = 0
--
Ticket URL: <http://core.trac.wordpress.org/ticket/19467#comment:6>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list