wordpress table:
I want update all fields values if it exists or insert a new values in a table if the values did not already exist.
I write following code, But I don’t know why doesn’t work.
$query = $wpdb->prepare (
"INSERT INTO ".$wpdb->prefix."price
(id, title, liveprice, changing, lowest,topest,time)
VALUES
(%d, %s, %s, %s,%s, %s, %s)
ON DUPLICATE KEY UPDATE
title = %s,
liveprice = %s,
changing = %s ,
lowest = %s,
topest = %s,
time = %s",
1,
trim($row->item(0)->nodeValue),
trim($row->item(2)->nodeValue),
trim($row->item(4)->nodeValue),
trim($row->item(6)->nodeValue),
trim($row->item(8)->nodeValue),
trim($row->item(10)->nodeValue)
);