update $wpdb one query – WordPress Development Stack Exchange

Question

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

0
Cong Tu Huyet 9 months 2022-09-10T20:23:42-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse