Updated database column names to match new SQL column naming

This commit is contained in:
Timo Smit 2016-03-09 11:39:32 +01:00
parent 3c60513190
commit 057c37d7e7

View file

@ -47,11 +47,11 @@ function mysql.getmap(mapname)
end end
function mysql.addrecord(mapid, recorddate, recordtype, record, playerid) function mysql.addrecord(mapid, recorddate, recordtype, record, playerid)
cur = assert(con:execute("INSERT INTO `record` (`mapid`, `date`, `type`, `record`, `player`) VALUES ("..tonumber(mapid)..", "..tonumber(recorddate)..", "..tonumber(recordtype)..", "..tonumber(record)..", "..tonumber(playerid)..")")) cur = assert(con:execute("INSERT INTO `record` (`map_id`, `date`, `type`, `record`, `player_id`) VALUES ("..tonumber(mapid)..", "..tonumber(recorddate)..", "..tonumber(recordtype)..", "..tonumber(record)..", "..tonumber(playerid)..")"))
end end
function mysql.updaterecord(mapid, recorddate, recordtype, record, playerid) function mysql.updaterecord(mapid, recorddate, recordtype, record, playerid)
cur = assert(con:execute("UPDATE `record` SET `date`="..tonumber(recorddate)..", `record`="..tonumber(record)..", `player`="..tonumber(playerid).." WHERE `mapid`="..tonumber(mapid).." AND `type`="..tonumber(recordtype).."")) cur = assert(con:execute("UPDATE `record` SET `date`="..tonumber(recorddate)..", `record`="..tonumber(record)..", `player_id`="..tonumber(playerid).." WHERE `map_id`="..tonumber(mapid).." AND `type`="..tonumber(recordtype)..""))
end end
function mysql.removeallrecords() function mysql.removeallrecords()
@ -59,11 +59,11 @@ function mysql.removeallrecords()
end end
function mysql.removerecords(mapid) function mysql.removerecords(mapid)
cur = assert(con:execute("DELETE FROM `record` WHERE `mapid`="..tonumber(mapid).."")) cur = assert(con:execute("DELETE FROM `record` WHERE `map_id`="..tonumber(mapid)..""))
end end
function mysql.getrecords(mapid) function mysql.getrecords(mapid)
cur = assert(con:execute("SELECT * FROM `record` WHERE `mapid`="..tonumber(mapid).."")) cur = assert(con:execute("SELECT * FROM `record` WHERE `map_id`="..tonumber(mapid)..""))
local numrows = cur:numrows() local numrows = cur:numrows()
local records = {} local records = {}
@ -89,7 +89,7 @@ function mysql.getrecords(mapid)
end end
function mysql.getrecordscount(mapid) function mysql.getrecordscount(mapid)
cur = assert(con:execute("SELECT COUNT(*) AS `count` FROM `record` WHERE `mapid`="..tonumber(mapid).."")) cur = assert(con:execute("SELECT COUNT(*) AS `count` FROM `record` WHERE `map_id`="..tonumber(mapid)..""))
local count = cur:fetch({}, "a") local count = cur:fetch({}, "a")
cur:close() cur:close()
@ -98,7 +98,7 @@ function mysql.getrecordscount(mapid)
end end
function mysql.getrecord(mapid, recordtype) function mysql.getrecord(mapid, recordtype)
cur = assert(con:execute("SELECT * FROM `record` WHERE `mapid`="..tonumber(mapid).." AND `type`="..tonumber(recordtype).."")) cur = assert(con:execute("SELECT * FROM `record` WHERE `map_id`="..tonumber(mapid).." AND `type`="..tonumber(recordtype)..""))
local row = cur:fetch({}, "a") local row = cur:fetch({}, "a")
cur:close() cur:close()
@ -143,7 +143,7 @@ function mysql.getplayer(guid)
end end
function mysql.addalias(playerid, alias, lastused) function mysql.addalias(playerid, alias, lastused)
cur = assert(con:execute("INSERT INTO `alias` (`player`, `alias`, `cleanalias`, `lastused`, `used`) VALUES ("..tonumber(playerid)..", '"..util.escape(alias).."', '"..util.escape(util.removeColors(alias)).."', "..tonumber(lastused)..", 1)")) cur = assert(con:execute("INSERT INTO `alias` (`player_id`, `alias`, `cleanalias`, `lastused`, `used`) VALUES ("..tonumber(playerid)..", '"..util.escape(alias).."', '"..util.escape(util.removeColors(alias)).."', "..tonumber(lastused)..", 1)"))
end end
function mysql.updatecleanalias(aliasid, alias) function mysql.updatecleanalias(aliasid, alias)
@ -155,7 +155,7 @@ function mysql.updatealias(aliasid, lastused)
end end
function mysql.getaliases(playerid) function mysql.getaliases(playerid)
cur = assert(con:execute("SELECT * FROM `alias` WHERE `player`="..tonumber(playerid).." ORDER BY `used` DESC")) cur = assert(con:execute("SELECT * FROM `alias` WHERE `player_id`="..tonumber(playerid).." ORDER BY `used` DESC"))
local numrows = cur:numrows() local numrows = cur:numrows()
local aliases = {} local aliases = {}
@ -178,7 +178,7 @@ function mysql.getaliasbyid(aliasid)
end end
function mysql.getaliasbyname(playerid, aliasname) function mysql.getaliasbyname(playerid, aliasname)
cur = assert(con:execute("SELECT * FROM `alias` WHERE `player`="..tonumber(playerid).." AND `alias`='"..util.escape(aliasname).."'")) cur = assert(con:execute("SELECT * FROM `alias` WHERE `player_id`="..tonumber(playerid).." AND `alias`='"..util.escape(aliasname).."'"))
local alias = cur:fetch({}, "a") local alias = cur:fetch({}, "a")
cur:close() cur:close()
@ -187,7 +187,7 @@ function mysql.getaliasbyname(playerid, aliasname)
end end
function mysql.getlastalias(playerid) function mysql.getlastalias(playerid)
cur = assert(con:execute("SELECT * FROM `alias` WHERE `player`="..tonumber(playerid).." ORDER BY `lastused` DESC LIMIT 1")) cur = assert(con:execute("SELECT * FROM `alias` WHERE `player_id`="..tonumber(playerid).." ORDER BY `lastused` DESC LIMIT 1"))
local alias = cur:fetch({}, "a") local alias = cur:fetch({}, "a")
cur:close() cur:close()
@ -196,11 +196,11 @@ function mysql.getlastalias(playerid)
end end
function mysql.addsetlevel(playerid, level, adminid, datetime) function mysql.addsetlevel(playerid, level, adminid, datetime)
cur = assert(con:execute("INSERT INTO `level` (`player`, `level`, `admin`, `datetime`) VALUES ("..tonumber(playerid)..", "..tonumber(level)..", "..tonumber(adminid)..", "..tonumber(datetime)..")")) cur = assert(con:execute("INSERT INTO `level` (`player_id`, `level`, `admin_id`, `datetime`) VALUES ("..tonumber(playerid)..", "..tonumber(level)..", "..tonumber(adminid)..", "..tonumber(datetime)..")"))
end end
function mysql.getlevels(playerid) function mysql.getlevels(playerid)
cur = assert(con:execute("SELECT * FROM `level` WHERE `player`="..tonumber(playerid).."")) cur = assert(con:execute("SELECT * FROM `level` WHERE `player_id`="..tonumber(playerid)..""))
local numrows = cur:numrows() local numrows = cur:numrows()
local levels = {} local levels = {}
@ -214,7 +214,7 @@ function mysql.getlevels(playerid)
end end
function mysql.addwarn(playerid, reason, adminid, datetime) function mysql.addwarn(playerid, reason, adminid, datetime)
cur = assert(con:execute("INSERT INTO `warn` (`player`, `reason`, `admin`, `datetime`) VALUES ("..tonumber(playerid)..", '"..util.escape(reason).."', "..tonumber(adminid)..", "..tonumber(datetime)..")")) cur = assert(con:execute("INSERT INTO `warn` (`player_id`, `reason`, `admin_id`, `datetime`) VALUES ("..tonumber(playerid)..", '"..util.escape(reason).."', "..tonumber(adminid)..", "..tonumber(datetime)..")"))
end end
function mysql.removewarn(warnid) function mysql.removewarn(warnid)
@ -222,7 +222,7 @@ function mysql.removewarn(warnid)
end end
function mysql.getwarns(playerid) function mysql.getwarns(playerid)
cur = assert(con:execute("SELECT * FROM `warn` WHERE `player`="..tonumber(playerid).."")) cur = assert(con:execute("SELECT * FROM `warn` WHERE `player_id`="..tonumber(playerid)..""))
local numrows = cur:numrows() local numrows = cur:numrows()
local warns = {} local warns = {}