Code:
--------------------------------------------------------------------------------------|
--\ Function: GetTableData
--------------------------------------------------------------------------------------|
function GetTableData(_DATABASE,_TABLE,_COLUMN,_ROW,_VALUE1,_VALUE2) local _T={}
if (string.upper(_DATABASE) == "CHARACTER") then _DB=1 end
if (string.upper(_DATABASE) == "WORLD") then _DB=0 end
_Q=Query(_DB, _ROW, "SELECT * FROM `".._TABLE.."` WHERE `".._VALUE1.."`='".._VALUE2.."'",0)
if (_Q ~= nil) then _T.L=_Q end if (_T.L ~= nil) then return _T.L end
end
--------------------------------------------------------------------------------------|
--\ Function: SetTableData
--------------------------------------------------------------------------------------|
function SetTableData(_DATABASE,_TABLE,_COLUMN,_NEWVALUE,_VALUE1,_VALUE2)
if (string.upper(_DATABASE) == "CHARACTER") then _DB=1 end
if (string.upper(_DATABASE) == "WORLD") then _DB=0 end
Query(_DB,1, "UPDATE `".._TABLE.."` SET `".._COLUMN.."`='".._NEWVALUE.."' WHERE `".._VALUE1.."`='".._VALUE2.."'",0)
end
You can use the functions like this:
Code:
GetTableData(DATABASE,TABLENAME,ROWNAME,ROWNUMBER,VALUE1,VALUE2)
Example:
GetTableData("Character","guilds","motd",9,"Guildname","The Uber Guild")
The above code will get the Message of the Day (9th row) of the guild where
the name is 'Uber Guild'. (where VALUE1 is equal to VALUE2)
SetTableData(DATABASE,TABLE,ROWNAME,NEWVALUE,VALUE1,VALUE2)
Example:
SetTableData("World","creature_names","name","Lord New Name","entry","200000")
The above function will change the name of the creature with entry 200000
to 'Lord New Name'.