DeleteBotGroup converted to QueryDatabase

This commit is contained in:
Arthur Ice 2014-09-03 17:47:38 -07:00
parent 36325226eb
commit 96cf3d967f

View File

@ -4721,27 +4721,26 @@ void Bot::SaveBotGroup(Group* botGroup, std::string botGroupName, std::string* e
} }
void Bot::DeleteBotGroup(std::string botGroupName, std::string* errorMessage) { void Bot::DeleteBotGroup(std::string botGroupName, std::string* errorMessage) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
if(!botGroupName.empty()) { if(botGroupName.empty())
uint32 botGroupId = GetBotGroupIdByBotGroupName(botGroupName, errorMessage); return;
if(errorMessage->empty() && botGroupId > 0) { uint32 botGroupId = GetBotGroupIdByBotGroupName(botGroupName, errorMessage);
if(!database.RunQuery(query, MakeAnyLenString(&query, "DELETE FROM botgroupmembers WHERE BotGroupId = %u", botGroupId), errbuf)) {
*errorMessage = std::string(errbuf);
}
else {
safe_delete_array(query);
if(!database.RunQuery(query, MakeAnyLenString(&query, "DELETE FROM botgroup WHERE BotGroupId = %u", botGroupId), errbuf)) { if(!errorMessage->empty() || botGroupId== 0)
*errorMessage = std::string(errbuf); return;
}
}
safe_delete_array(query); std::string query = StringFormat("DELETE FROM botgroupmembers WHERE BotGroupId = %u", botGroupId);
} auto results = database.QueryDatabase(query);
} if(!results.Success()) {
*errorMessage = std::string(results.ErrorMessage());
return;
}
query = StringFormat("DELETE FROM botgroup WHERE BotGroupId = %u", botGroupId);
results = database.QueryDatabase(query);
if(!results.Success())
*errorMessage = std::string(results.ErrorMessage());
} }
std::list<BotGroup> Bot::LoadBotGroup(std::string botGroupName, std::string* errorMessage) { std::list<BotGroup> Bot::LoadBotGroup(std::string botGroupName, std::string* errorMessage) {