GuildWarList IOGuild::getWarList(uint32_t guildId) { GuildWarList guildWarList; Database* db = Database::getInstance(); DBQuery query; DBResult* result; query << "SELECT `guild1` FROM `guild_wars` WHERE `guild2` = " << guildId << " AND `ended` = 0 AND `status` = 1;"; if((result = db->storeQuery(query.str()))) { do { guildWarList.push_back(result->getDataInt("guild1")); } while (result->next()); db->freeResult(result); } query.str(""); query << "SELECT `guild2` FROM `guild_wars` WHERE `guild1` = " << guildId << " AND `ended` = 0 AND `status` = 1;"; if((result = db->storeQuery(query.str()))) { do { guildWarList.push_back(result->getDataInt("guild2")); } while (result->next()); db->freeResult(result); } return guildWarList; }
void IOGuild::getWarList(uint32_t guildId, GuildWarList& guildWarList) { std::ostringstream query; query << "SELECT `guild1`, `guild2` FROM `guild_wars` WHERE (`guild1` = " << guildId << " OR `guild2` = " << guildId << ") AND `ended` = 0 AND `status` = 1"; DBResult_ptr result = Database::getInstance()->storeQuery(query.str()); if (!result) { return; } do { uint32_t guild1 = result->getDataInt("guild1"); if (guildId != guild1) { guildWarList.push_back(guild1); } else { guildWarList.push_back(result->getDataInt("guild2")); } } while (result->next()); }