WordPress Query doesn’t return the correct value

Question

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 = &#039;foo&#039;, blurb = &#039;trey&#039;, email = &#039;foo@dummy.com&#039;, tel = &#039;123456&#039;, www = &#039;https://google.com/&#039;, addr_line_1 = &#039;some place&#039;, addr_line_2 = &#039;&#039;, addr_line_3 = &#039;&#039;, town = &#039;A town&#039;, county = &#039;county&#039;, post_code = &#039;SOME PLACE&#039;, 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

0
, treyBake 2 years 2020-01-06T08:39:10-05:00 0 Answers 89 views 0

Leave an answer

Browse
Browse