ExpiredMarketOfferList IOMarket::getExpiredOffers(MarketAction_t action) { ExpiredMarketOfferList offerList; const time_t lastExpireDate = time(nullptr) - g_config.getNumber(ConfigManager::MARKET_OFFER_DURATION); std::ostringstream query; query << "SELECT `id`, `amount`, `price`, `itemtype`, `player_id` FROM `market_offers` WHERE `sale` = " << action << " AND `created` <= " << lastExpireDate; Database* db = Database::getInstance(); DBResult* result = db->storeQuery(query.str()); if (!result) { return offerList; } do { ExpiredMarketOffer offer; offer.id = result->getDataInt("id"); offer.amount = result->getDataInt("amount"); offer.price = result->getDataInt("price"); offer.itemId = result->getDataInt("itemtype"); offer.playerId = result->getDataInt("player_id"); offerList.push_back(offer); } while (result->next()); db->freeResult(result); return offerList; }
ExpiredMarketOfferList IOMarket::getExpiredOffers(MarketAction_t action) { Database* db = Database::getInstance(); DBQuery query; query << "SELECT `id`, `amount`, `price`, `itemtype`, `player_id` FROM `market_offers` WHERE `sale` = " << action << " AND `created` <= " << (time(NULL) - g_config.getNumber(ConfigManager::MARKET_OFFER_DURATION)) << " AND `world_id` = " << g_config.getNumber(ConfigManager::WORLD_ID) << ";"; DBResult* result; if(!(result = db->storeQuery(query.str()))) return ExpiredMarketOfferList(); ExpiredMarketOfferList offerList; do { ExpiredMarketOffer offer; offer.id = result->getDataInt("id"); offer.amount = result->getDataInt("amount"); offer.price = result->getDataInt("price"); offer.itemId = result->getDataInt("itemtype"); offer.playerId = result->getDataInt("player_id"); offerList.push_back(offer); } while(result->next()); result->free(); return offerList; }