I'm trying to create a statement that inserts and updates rows in my database which changes a value in my database when values has changed while updating the row.
I'm not sure if my question is clear enough but here is my code (check the comments, this should clear things up):
$stmProducts = $db->prepare("
INSERT INTO
products
SET
identifier = :identifier,
title = :title,
price = :price,
content = :content
ON DUPLICATE KEY UPDATE
title = :title,
price = :price,
content = :content
// If any values (title, price or content) has been changed while updating:
// updated = true
");
I've tried something with CASE WHEN but that didn't work, I don't have the exact code I used but it was something like this:
updated = CASE WHEN title != :title THEN true END
I could be looking into the completely wrong direction but what's the best way to get to what I'm trying to achieve?