fixed query issues

This commit is contained in:
jenz 2023-04-11 23:19:07 +02:00
parent 7c74bb9cf6
commit c203a9c091

View File

@ -102,9 +102,16 @@ public void Command_listcmd()
if (StrEqual(Description, "", false)) if (StrEqual(Description, "", false))
Format(Description, sizeof(Description), "No description found"); Format(Description, sizeof(Description), "No description found");
//PrintToChatAll("Command: %s Description: %s strFlags: %s", Command, Description, strFlags); //PrintToChatAll("Command: %s Description: %s strFlags: %s", Command, Description, strFlags);
char sQuery[512]; char sQuery[2048];
Format(sQuery, sizeof(sQuery), "INSERT INTO `ze_commands_info` (`command`, `description`, `flag`) VALUES ('%s', '%s', '%s') ON DUPLICATE KEY UPDATE `description` = '%s', `flag` = '%s'", Command, Description, strFlags, Description, strFlags); int size2 = 2 * strlen(Description) + 1;
g_hDatabase.Query(SQL_OnQueryCompleted, sQuery, DBPrio_Low); char[] sEscapedDescription = new char[size2 + 1];
g_hDatabase.Escape(Description, sEscapedDescription, size2 + 1);
Format(sQuery, sizeof(sQuery), "INSERT INTO `ze_commands_info` (`command`, `description`, `flag`) VALUES ('%s', '%s', '%s') ON DUPLICATE KEY UPDATE `description` = '%s', `flag` = '%s'", Command, sEscapedDescription, strFlags, sEscapedDescription, strFlags);
DataPack hDataPack = new DataPack();
hDataPack.WriteString(sQuery);
g_hDatabase.Query(SQL_OnQueryCompleted, sQuery, hDataPack, DBPrio_Low);
} }
CloseHandle(hIterator); CloseHandle(hIterator);
} }
@ -113,8 +120,12 @@ public void SQL_OnQueryCompleted(Database db, DBResultSet results, const char[]
{ {
if (!db || strlen(error)) if (!db || strlen(error))
{ {
char sQuery[2048];
ResetPack(data);
data.ReadString(sQuery, sizeof(sQuery));
LogError("Query error 3: %s", error); LogError("Query error 3: %s", error);
delete results; LogError("actual query: %s", sQuery);
} }
delete results;
delete data; delete data;
} }