Converted ClearRaid to QueryDatabase, added ClearAllRaids utility method

This commit is contained in:
Arthur Ice 2014-07-05 19:33:45 -07:00 committed by Arthur Ice
parent c80f803ba7
commit 34739b71b3
2 changed files with 31 additions and 9 deletions

View File

@ -1990,16 +1990,32 @@ void Database::SetAgreementFlag(uint32 acctid)
} }
void Database::ClearRaid(uint32 rid) { void Database::ClearRaid(uint32 rid) {
char errbuf[MYSQL_ERRMSG_SIZE]; char *query = nullptr;
char *query = 0;
if(rid == 0) { //clear all raids if(rid == 0)
if (!RunQuery(query, MakeAnyLenString(&query, "delete from raid_members"), errbuf)) {
printf("Unable to clear raids: %s\n",errbuf); //clear all raids
} else { //clear a specific group ClearAllRaids();
if (!RunQuery(query, MakeAnyLenString(&query, "delete from raid_members where raidid = %lu", (unsigned long)rid), errbuf)) return;
printf("Unable to clear raids: %s\n",errbuf); }
}
//clear a specific group
auto results = QueryDatabase(query, MakeAnyLenString(&query, "delete from raid_members where raidid = %lu", (unsigned long)rid));
safe_delete_array(query); safe_delete_array(query);
if (!results.Success())
std::cout << "Unable to clear raids: " << results.ErrorMessage() << std::endl;
}
void Database::ClearAllRaids(void)
{
char *query = nullptr;
auto results = QueryDatabase(query, MakeAnyLenString(&query, "delete from raid_members"));
safe_delete_array(query);
if (!results.Success())
std::cout << "Unable to clear raids: " << results.ErrorMessage() << std::endl;
} }
void Database::ClearRaidDetails(uint32 rid) { void Database::ClearRaidDetails(uint32 rid) {

View File

@ -270,6 +270,12 @@ private:
*/ */
void ClearAllGroupLeaders(); void ClearAllGroupLeaders();
void ClearAllGroups(); void ClearAllGroups();
/*
* Raid, utility methods.
*/
void ClearAllRaids();
}; };
bool FetchRowMap(MYSQL_RES *result, std::map<std::string,std::string> &rowmap); bool FetchRowMap(MYSQL_RES *result, std::map<std::string,std::string> &rowmap);