Mercurial > hg > fapweb
changeset 762:539bfbdd43ec
Add timestamps to votes, bump database version.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 20 Nov 2014 11:43:34 +0200 |
parents | 1be30385e9d4 |
children | 20fd7d2040d1 |
files | dbdefs.inc.php usrajax.php |
diffstat | 2 files changed, 7 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/dbdefs.inc.php Thu Nov 20 11:42:29 2014 +0200 +++ b/dbdefs.inc.php Thu Nov 20 11:43:34 2014 +0200 @@ -1,6 +1,6 @@ <? -$dbVersion = 21; +$dbVersion = 22; // // Site settings and defaults we put in @@ -297,6 +297,7 @@ array("entry_id" , "INT", "DEFAULT NULL"), array("key_id" , "INT", "DEFAULT 0"), array("value" , "INT", "DEFAULT 0"), + array("utime" , "INT", "DEFAULT 0"), ),
--- a/usrajax.php Thu Nov 20 11:42:29 2014 +0200 +++ b/usrajax.php Thu Nov 20 11:43:34 2014 +0200 @@ -22,15 +22,15 @@ { // Didn't exist, insert it $sql = stPrepareSQL( - "INSERT INTO votes (key_id,entry_id,value) VALUES (%d,%d,%d)", - $key_id, $entry_id, $vote); + "INSERT INTO votes (key_id,entry_id,value,utime) VALUES (%d,%d,%d,%d)", + $key_id, $entry_id, $vote, time()); } else { // Existed, thusly update - $sql = stPrepareSQL( - "UPDATE votes SET value=%d WHERE key_id=%d AND entry_id=%d", - $vote, $key_id, $entry_id); + $sql = stPrepareSQLUpdate( + "UPDATE votes SET value=%d,utime=%d WHERE key_id=%d AND entry_id=%d", + $vote, time(), $key_id, $entry_id); } return stExecSQL($sql);