当前位置: 首页>>代码示例>>C++>>正文


C++ DBResult::getDataInt方法代码示例

本文整理汇总了C++中DBResult::getDataInt方法的典型用法代码示例。如果您正苦于以下问题:C++ DBResult::getDataInt方法的具体用法?C++ DBResult::getDataInt怎么用?C++ DBResult::getDataInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBResult的用法示例。


在下文中一共展示了DBResult::getDataInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadAccount

Account IOAccount::loadAccount(uint32_t accno)
{
	Account acc;

	Database* db = Database::instance();
	DBQuery query;
	DBResult* result;

	query << "SELECT `id`, `password`, `premend`, `warnings` FROM `accounts` WHERE `id` = " << accno;
	if((result = db->storeQuery(query.str()))){
		acc.accnumber = result->getDataInt("id");
		acc.password = result->getDataString("password");
		acc.premEnd = result->getDataInt("premend");
		acc.warnings = result->getDataInt("warnings");
		db->freeResult(result);

		query.str("");
		query << "SELECT `name` FROM `players` WHERE `account_id` = " << accno;
		if((result = db->storeQuery(query.str()))){
			do {
				std::string ss = result->getDataString("name");
				acc.charList.push_back(ss.c_str());
			} while(result->next());

			acc.charList.sort();
			db->freeResult(result);
		}
	}

	return acc;
}
开发者ID:Codex-NG,项目名称:avesta74,代码行数:31,代码来源:ioaccount.cpp

示例2: updateAuctions

bool IOMapSerialize::updateAuctions()
{
	Database* db = Database::getInstance();
	DBQuery query;

	time_t now = time(NULL);
	query << "SELECT `house_id`, `player_id`, `bid` FROM `house_auctions` WHERE `endtime` < " << now;

	DBResult* result;
	if(!(result = db->storeQuery(query.str())))
		return true;

	bool success = true;
	House* house = NULL;
	do
	{
		query.str("");
		query << "DELETE FROM `house_auctions` WHERE `house_id` = " << result->getDataInt("house_id");
		if(!(house = Houses::getInstance()->getHouse(result->getDataInt(
			"house_id"))) || !db->query(query.str()))
		{
			success = false;
			continue;
		}

		house->setOwner(result->getDataInt("player_id"));
		Houses::getInstance()->payHouse(house, now, result->getDataInt("bid"));
	}
	while(result->next());
	result->free();
	return success;
}
开发者ID:Codex-NG,项目名称:TheImaginedServer,代码行数:32,代码来源:iomapserialize.cpp

示例3: getWarList

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;
}
开发者ID:armadaazteca,项目名称:tfs0.2.15,代码行数:28,代码来源:ioguild.cpp

示例4: getPlayerGroup

const PlayerGroup* IOPlayer::getPlayerGroup(uint32_t groupid)
{
	PlayerGroupMap::const_iterator it = playerGroupMap.find(groupid);

	if(it != playerGroupMap.end()){
		return it->second;
	}
	else{
		Database* db = Database::instance();
		DBQuery query;
		DBResult* result;

		query << "SELECT * FROM `groups` WHERE `id`= " << groupid;

		if((result = db->storeQuery(query.str()))){
			PlayerGroup* group = new PlayerGroup;

			group->m_name = result->getDataString("name");
			group->m_flags = result->getDataLong("flags");
			group->m_access = result->getDataInt("access");
			group->m_maxDepotItems = result->getDataInt("maxdepotitems");
			group->m_maxVip = result->getDataInt("maxviplist");

			playerGroupMap[groupid] = group;

			db->freeResult(result);
			return group;
		}
	}
	return NULL;
}
开发者ID:gianflogao,项目名称:divinity-ots,代码行数:31,代码来源:ioplayer.cpp

示例5: while

std::list<VIPEntry> IOLoginData::getVIPEntries(uint32_t accountId)
{
	std::list<VIPEntry> entries;

	Database* db = Database::getInstance();

	std::ostringstream query;
	query << "SELECT `player_id`, (SELECT `name` FROM `players` WHERE `id` = `player_id`) AS `name`, `description`, `icon`, `notify` FROM `account_viplist` WHERE `account_id` = " << accountId;

	DBResult* result;

	if ((result = db->storeQuery(query.str()))) {
		do {
			VIPEntry entry;
			entry.guid = result->getDataInt("player_id");
			entry.name = result->getDataString("name");
			entry.description = result->getDataString("description");
			entry.icon = result->getDataInt("icon");
			entry.notify = result->getDataInt("notify") != 0;
			entries.push_back(entry);
		} while (result->next());

		db->freeResult(result);
	}

	return entries;
}
开发者ID:oneshot-git,项目名称:forgottenserver,代码行数:27,代码来源:iologindata.cpp

示例6: getOwnOffers

MarketOfferList IOMarket::getOwnOffers(MarketAction_t action, uint32_t playerId)
{
	Database* db = Database::getInstance();
	DBQuery query;
	query << "SELECT `id`, `amount`, `price`, `created`, `anonymous`, `itemtype` FROM `market_offers` WHERE `player_id` = "
		<< playerId << " AND `sale` = " << action << " AND `world_id` = " << g_config.getNumber(ConfigManager::WORLD_ID) << ";";

	DBResult* result;
	if(!(result = db->storeQuery(query.str())))
		return MarketOfferList();

	MarketOfferList offerList;
	do
	{
		MarketOffer offer;
		offer.amount = result->getDataInt("amount");
		offer.price = result->getDataInt("price");
		offer.timestamp = result->getDataInt("created") + g_config.getNumber(ConfigManager::MARKET_OFFER_DURATION);
		offer.counter = result->getDataInt("id") & 0xFFFF;
		offer.itemId = result->getDataInt("itemtype");

		offerList.push_back(offer);
	}
	while(result->next());
	result->free();
	return offerList;
}
开发者ID:081421,项目名称:otxserver,代码行数:27,代码来源:iomarket.cpp

示例7: getOwnOffers

MarketOfferList IOMarket::getOwnOffers(MarketAction_t action, uint32_t playerId)
{
	MarketOfferList offerList;

	const int32_t marketOfferDuration = g_config.getNumber(ConfigManager::MARKET_OFFER_DURATION);

	std::ostringstream query;
	query << "SELECT `id`, `amount`, `price`, `created`, `anonymous`, `itemtype` FROM `market_offers` WHERE `player_id` = " << playerId << " AND `sale` = " << action;

	Database* db = Database::getInstance();

	DBResult* result = db->storeQuery(query.str());
	if (!result) {
		return offerList;
	}

	do {
		MarketOffer offer;
		offer.amount = result->getDataInt("amount");
		offer.price = result->getDataInt("price");
		offer.timestamp = result->getDataInt("created") + marketOfferDuration;
		offer.counter = result->getDataInt("id") & 0xFFFF;
		offer.itemId = result->getDataInt("itemtype");

		offerList.push_back(offer);
	} while (result->next());

	db->freeResult(result);
	return offerList;
}
开发者ID:AhmedWaly,项目名称:forgottenserver,代码行数:30,代码来源:iomarket.cpp

示例8: getGuidByNameEx

bool IOLoginData::getGuidByNameEx(uint32_t& guid, bool& specialVip, std::string& name)
{
	Database* db = Database::getInstance();

	std::ostringstream query;
	query << "SELECT `name`, `id`, `group_id`, `account_id` FROM `players` WHERE `name` = " << db->escapeString(name);

	DBResult* result = db->storeQuery(query.str());
	if (!result) {
		return false;
	}

	name = result->getDataString("name");
	guid = result->getDataInt("id");
	Group* group = g_game.getGroup(result->getDataInt("group_id"));
	db->freeResult(result);

	uint64_t flags;
	if (group) {
		flags = group->flags;
	} else {
		flags = 0;
	}

	specialVip = (0 != (flags & ((uint64_t)1 << PlayerFlag_SpecialVIP)));
	return true;
}
开发者ID:oneshot-git,项目名称:forgottenserver,代码行数:27,代码来源:iologindata.cpp

示例9: getExpiredOffers

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;
}
开发者ID:AhmedWaly,项目名称:forgottenserver,代码行数:30,代码来源:iomarket.cpp

示例10: getPlayerGroup

const PlayerGroup* IOLoginData::getPlayerGroup(uint32_t groupid)
{
	PlayerGroupMap::const_iterator it = playerGroupMap.find(groupid);
	if (it != playerGroupMap.end()) {
		return it->second;
	}

	Database* db = Database::getInstance();

	std::ostringstream query;
	query << "SELECT `name`, `flags`, `access`, `maxdepotitems`, `maxviplist` FROM `groups` WHERE `id` = " << groupid;

	DBResult* result = db->storeQuery(query.str());
	if (!result) {
		return NULL;
	}

	PlayerGroup* group = new PlayerGroup;
	group->m_name = result->getDataString("name");
	group->m_flags = result->getDataLong("flags");
	group->m_access = result->getDataInt("access");
	group->m_maxdepotitems = result->getDataInt("maxdepotitems");
	group->m_maxviplist = result->getDataInt("maxviplist");
	db->freeResult(result);

	playerGroupMap[groupid] = group;
	return group;
}
开发者ID:24312108k,项目名称:forgottenserver,代码行数:28,代码来源:iologindata.cpp

示例11: updateWar

bool IOGuild::updateWar(War_t& war)
{
	Database* db = Database::getInstance();
	DBResult* result;

	DBQuery query;
	query << "SELECT `g`.`name` AS `guild_name`, `e`.`name` AS `enemy_name`, `w`.* FROM `guild_wars` w LEFT JOIN `guilds` g ON `w`.`guild_id` = `g`.`id` LEFT JOIN `guilds` e ON `w`.`enemy_id` = `e`.`id` WHERE `w`.`id` = " << war.war;
	if(!(result = db->storeQuery(query.str())))
		return false;

	war.ids[WAR_GUILD] = result->getDataInt("guild_id");
	war.ids[WAR_ENEMY] = result->getDataInt("enemy_id");
	war.names[WAR_GUILD] = result->getDataString("guild_name");
	war.names[WAR_ENEMY] = result->getDataString("enemy_name");

	war.frags[WAR_GUILD] = result->getDataInt("guild_kills");
	war.frags[WAR_ENEMY] = result->getDataInt("enemy_kills");
	war.frags[war.type]++;

	war.limit = result->getDataInt("frags");
	war.payment = result->getDataInt("payment");

	result->free();
	if(war.frags[WAR_GUILD] >= war.limit || war.frags[WAR_ENEMY] >= war.limit)
	{
		Scheduler::getInstance().addEvent(createSchedulerTask(1000,
			boost::bind(&IOGuild::finishWar, this, war, true)));
		return true;
	}

	query.str("");
	query << "UPDATE `guild_wars` SET `guild_kills` = " << war.frags[WAR_GUILD] << ", `enemy_kills` = " << war.frags[WAR_ENEMY] << " WHERE `id` = " << war.war;
	return db->query(query.str());
}
开发者ID:081421,项目名称:otxserver,代码行数:34,代码来源:ioguild.cpp

示例12: getOwnHistory

HistoryMarketOfferList IOMarket::getOwnHistory(MarketAction_t action, uint32_t playerId)
{
	Database* db = Database::getInstance();
	DBQuery query;
	query << "SELECT `id`, `itemtype`, `amount`, `price`, `expires_at`, `state` FROM `market_history` WHERE `player_id` = "
		<< playerId << " AND `sale` = " << action << " AND `world_id` = " << g_config.getNumber(ConfigManager::WORLD_ID) << ";";

	DBResult* result;
	if(!(result = db->storeQuery(query.str())))
		return HistoryMarketOfferList();

	HistoryMarketOfferList offerList;
	do
	{
		HistoryMarketOffer offer;
		offer.itemId = result->getDataInt("itemtype");
		offer.amount = result->getDataInt("amount");
		offer.price = result->getDataInt("price");
		offer.timestamp = result->getDataInt("expires_at");

		MarketOfferState_t offerState = (MarketOfferState_t)result->getDataInt("state");
		if(offerState == OFFERSTATE_ACCEPTEDEX)
			offerState = OFFERSTATE_ACCEPTED;

		offer.state = offerState;
		offerList.push_back(offer);
	}
	while(result->next());
	result->free();
	return offerList;
}
开发者ID:081421,项目名称:otxserver,代码行数:31,代码来源:iomarket.cpp

示例13: getExpiredOffers

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;
}
开发者ID:081421,项目名称:otxserver,代码行数:27,代码来源:iomarket.cpp

示例14: getOwnHistory

HistoryMarketOfferList IOMarket::getOwnHistory(MarketAction_t action, uint32_t playerId)
{
	HistoryMarketOfferList offerList;

	std::ostringstream query;
	query << "SELECT `id`, `itemtype`, `amount`, `price`, `expires_at`, `state` FROM `market_history` WHERE `player_id` = " << playerId << " AND `sale` = " << action;

	Database* db = Database::getInstance();

	DBResult* result = db->storeQuery(query.str());
	if (!result) {
		return offerList;
	}

	do {
		HistoryMarketOffer offer;
		offer.itemId = result->getDataInt("itemtype");
		offer.amount = result->getDataInt("amount");
		offer.price = result->getDataInt("price");
		offer.timestamp = result->getDataInt("expires_at");

		MarketOfferState_t offerState = (MarketOfferState_t)result->getDataInt("state");

		if (offerState == OFFERSTATE_ACCEPTEDEX) {
			offerState = OFFERSTATE_ACCEPTED;
		}

		offer.state = offerState;

		offerList.push_back(offer);
	} while (result->next());

	db->freeResult(result);
	return offerList;
}
开发者ID:AhmedWaly,项目名称:forgottenserver,代码行数:35,代码来源:iomarket.cpp

示例15:

std::vector<Ban> BanManager::getBans(const BanType_t& type)
{
	assert(type == BAN_IPADDRESS || type == BAN_PLAYER || type == BAN_ACCOUNT || type == BAN_NOTATION);
	Database* db = Database::instance();
	DBQuery query;
	query <<
	      "SELECT "
	      "`id`, "
	      "`value`, "
	      "`param`, "
	      "`expires`, "
	      "`added`, "
	      "`admin_id`, "
	      "`comment`, "
	      "`reason`, "
	      "`action`, "
	      "`statement` "
	      "FROM "
	      "`bans` "
	      "WHERE "
	      "`type` = " << type << " AND "
	      "`active` = 1 AND " <<
	      "(`expires` >= " << std::time(NULL) << " OR `expires` = 0)";
	std::vector<Ban> vec;
	DBResult* result;

	if (!(result = db->storeQuery(query.str())))
	{
		return vec;
	}

	do
	{
		Ban ban;
		ban.type = type;
		ban.id = result->getDataInt("id");
		ban.value = result->getDataString("value");
		ban.param = result->getDataString("param");
		ban.expires = result->getDataLong("expires");
		ban.added = (uint32_t)result->getDataLong("id");
		ban.adminId = result->getDataInt("admin_id");
		ban.reason = result->getDataInt("reason");
		ban.action = (violationAction_t)result->getDataInt("action");
		ban.comment = result->getDataString("comment");
		ban.statement = result->getDataString("statement");
		vec.push_back(ban);
	}
	while (result->next());

	db->freeResult(result);
	return vec;
}
开发者ID:edubart,项目名称:otserv,代码行数:52,代码来源:ban.cpp


注:本文中的DBResult::getDataInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。