feat: add support for parameterized SQL queries with argument escaping (#221)
This commit is contained in:
@@ -1334,6 +1334,10 @@ namespace LuaGlobalFunctions
|
||||
{
|
||||
const char* query = Eluna::CHECKVAL<const char*>(L, 1);
|
||||
|
||||
int numArgs = lua_gettop(L);
|
||||
if (numArgs > 1)
|
||||
query = Eluna::FormatQuery(L, query).c_str();
|
||||
|
||||
ElunaQuery result = WorldDatabase.Query(query);
|
||||
if (result)
|
||||
Eluna::Push(L, new ElunaQuery(result));
|
||||
@@ -1382,6 +1386,11 @@ namespace LuaGlobalFunctions
|
||||
int WorldDBExecute(lua_State* L)
|
||||
{
|
||||
const char* query = Eluna::CHECKVAL<const char*>(L, 1);
|
||||
|
||||
int numArgs = lua_gettop(L);
|
||||
if (numArgs > 1)
|
||||
query = Eluna::FormatQuery(L, query).c_str();
|
||||
|
||||
WorldDatabase.Execute(query);
|
||||
return 0;
|
||||
}
|
||||
@@ -1402,6 +1411,10 @@ namespace LuaGlobalFunctions
|
||||
{
|
||||
const char* query = Eluna::CHECKVAL<const char*>(L, 1);
|
||||
|
||||
int numArgs = lua_gettop(L);
|
||||
if (numArgs > 1)
|
||||
query = Eluna::FormatQuery(L, query).c_str();
|
||||
|
||||
QueryResult result = CharacterDatabase.Query(query);
|
||||
if (result)
|
||||
Eluna::Push(L, new QueryResult(result));
|
||||
@@ -1443,6 +1456,11 @@ namespace LuaGlobalFunctions
|
||||
int CharDBExecute(lua_State* L)
|
||||
{
|
||||
const char* query = Eluna::CHECKVAL<const char*>(L, 1);
|
||||
|
||||
int numArgs = lua_gettop(L);
|
||||
if (numArgs > 1)
|
||||
query = Eluna::FormatQuery(L, query).c_str();
|
||||
|
||||
CharacterDatabase.Execute(query);
|
||||
return 0;
|
||||
}
|
||||
@@ -1463,6 +1481,10 @@ namespace LuaGlobalFunctions
|
||||
{
|
||||
const char* query = Eluna::CHECKVAL<const char*>(L, 1);
|
||||
|
||||
int numArgs = lua_gettop(L);
|
||||
if (numArgs > 1)
|
||||
query = Eluna::FormatQuery(L, query).c_str();
|
||||
|
||||
QueryResult result = LoginDatabase.Query(query);
|
||||
if (result)
|
||||
Eluna::Push(L, new QueryResult(result));
|
||||
@@ -1504,6 +1526,11 @@ namespace LuaGlobalFunctions
|
||||
int AuthDBExecute(lua_State* L)
|
||||
{
|
||||
const char* query = Eluna::CHECKVAL<const char*>(L, 1);
|
||||
|
||||
int numArgs = lua_gettop(L);
|
||||
if (numArgs > 1)
|
||||
query = Eluna::FormatQuery(L, query).c_str();
|
||||
|
||||
LoginDatabase.Execute(query);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user