According to this page:
Return #Return
(int|bool) Boolean true for CREATE, ALTER, TRUNCATE and DROP queries. Number of rows affected/selected for all other queries. Boolean false on error.
From this, I can see that I should get a "number of rows affected" value returned, however - it's returning false.
Usually, this indicates an error and can see that a bool false on return = error. But this is where it gets a bit weird, the data is updated, yet the query is apparently a fail?
This my current code:
if (!$this->conn->query($this->conn->prepare($this->qry, $values))) {
var_dump($this->conn->print_error());
}
which prints:
<div id="error"><p class="wpdberror"><strong>WordPress database error:</strong> []<br /><code>UPDATE `wp_eng_dm_dealers` SET name = 'foo', blurb = 'trey', email = '[email protected]', tel = '123456', www = '/', addr_line_1 = 'some place', addr_line_2 = '', addr_line_3 = '', town = 'A town', county = 'county', post_code = 'SOME PLACE', lat = XYZ, lng = XYZ, dealer_type_id = 1, dealer_of_the_month = 1 WHERE id = 4</code></p></div>NULL
using the last_error
property, I got:
string(0) ""
decoding the code wrapped in the <code>
tag, I get a valid SQL statement, yet my conditionals never work because WP is returning a successful update as false. How can I go about debugging and resolving the issue?
WordPress version: 5.3.2
According to this page:
Return #Return
(int|bool) Boolean true for CREATE, ALTER, TRUNCATE and DROP queries. Number of rows affected/selected for all other queries. Boolean false on error.
From this, I can see that I should get a "number of rows affected" value returned, however - it's returning false.
Usually, this indicates an error and can see that a bool false on return = error. But this is where it gets a bit weird, the data is updated, yet the query is apparently a fail?
This my current code:
if (!$this->conn->query($this->conn->prepare($this->qry, $values))) {
var_dump($this->conn->print_error());
}
which prints:
<div id="error"><p class="wpdberror"><strong>WordPress database error:</strong> []<br /><code>UPDATE `wp_eng_dm_dealers` SET name = 'foo', blurb = 'trey', email = '[email protected]', tel = '123456', www = 'https://google/', addr_line_1 = 'some place', addr_line_2 = '', addr_line_3 = '', town = 'A town', county = 'county', post_code = 'SOME PLACE', lat = XYZ, lng = XYZ, dealer_type_id = 1, dealer_of_the_month = 1 WHERE id = 4</code></p></div>NULL
using the last_error
property, I got:
string(0) ""
decoding the code wrapped in the <code>
tag, I get a valid SQL statement, yet my conditionals never work because WP is returning a successful update as false. How can I go about debugging and resolving the issue?
Share Improve this question edited Jun 15, 2020 at 8:21 CommunityBot 1 asked Jan 6, 2020 at 12:56 treyBaketreyBake 12712 bronze badgesWordPress version: 5.3.2
1 Answer
Reset to default 0As it turns out, WordPress actually checks to see if the data posted matches existing data, if so, don't do anything and return false.
I was clicking my update button expecting it to just update in the database regardless, but it's not the case:
Taken from here