I want to prevent of taking back the vote by user after 5 minutes. Also because my website has both +1 and -1, I have ON DUPLICATE KEY UPDATE in INSERT query. Here is my query:
ON DUPLICATE KEY UPDATE
value = IF(last_seen > UNIX_TIMESTAMP() - 300 , value, (-1)*value)
For your information: IF function has this structure:
IF (expression ,expr_true, expr_false);
I used value if expression is true (updating the new value), and I used (-1)*value if expression is false (updating the old value).
Now I want to show the user that your new value updated or your time is over for updating. How can I control the error ?
Aucun commentaire:
Enregistrer un commentaire