[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
Wed Dec 7 15:47:26 UTC 2011
#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: Awaiting Review
Component: Database | Version: 3.3
Severity: trivial | Keywords: has-patch
--------------------------+-----------------------------
If SQL keywords like `INSERT` or `UPDATE` are not followed by a space, the
`rows_affected` and `insert_id` properties of the `wpdb` class are not
updated. Those keywords might be followed by a newline or a tab character.
A simple regex tweak fixes this issue.
{{{
#!php
<?php
// Note the newline after "UPDATE"
$wpdb->query('
UPDATE
test_table
SET foo = "bar"
WHERE id = 5
');
// Should not be int(0) in this case
var_dump($wpdb->rows_affected);
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/19467>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list