0

Is there a way to change mysql directly in wordpress just 1 operation without needing 2 operations: query and update?

I am facing problem of multiple concurrent transactions impacting point_user

I found the solution here, however I don't know how to implement it on wordpress

https://dba.stackexchange.com/questions/60681/transaction-basics-what-is-the-result-of-2-transactions-running-concurrently

Demo query sql

UPDATE wp_postmeta SET meta_value = meta_value - 1  WHERE post_id = 9999 AND meta_key = 'point_user'

Is there a way to update it like this?

global $wpdb;
$wpdb->query($wpdb->prepare("UPDATE wp_postmeta SET meta_value = meta_value - 1  WHERE post_id= 9999 AND meta_key = 'point_user'"));

I'm stuck, many thanks for your support

1 Answer 1

0

Try removing the $wpdb->prepare.

$wpdb->query("UPDATE wp_postmeta SET meta_value = meta_value - 1  WHERE post_id= 9999 AND meta_key = 'point_user'");
1
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Sep 28, 2022 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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