0

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

As 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:

enter image description here

Taken from here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.