$wpdb->query() fails when multiple UPDATE statements are used
-
Issue:
I am making PHP build a MySQL statement inside of a string, based on changes it detects in an array.
The following statement succeeds with $wpdb->query()
UPDATE MyTable_artists SET first_name = "Jacob", thumbnail = "Option 2" WHERE id = "1";
However, the following statement fails with $wpdb->query()
UPDATE MyTable_artists SET first_name = "Jacob", thumbnail = "Option 2" WHERE id = "1"; UPDATE MyTable_artists SET thumbnail = "Option 2" WHERE id = "2"; UPDATE MyTable_artists SET thumbnail = "Option 2" WHERE id = "4";
Extra Info:
The statement only seems to succeed when running a single UPDATE. More than one UPDATE statement seems to cause a failure.
This is strange in that running the multiple UPDATE statements through PhpMyAdmin does not produce any errors.
Running the string variable through a var_dump() does not reveal any strange characters hiding within the string.
Solution:
No solution yet – Any insights or suggestions are greatly appreciated, and I will update this ticket once I discover what is wrong.
- The topic ‘$wpdb->query() fails when multiple UPDATE statements are used’ is closed to new replies.