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


C++ DatabaseDriver::executeQuery方法代码示例

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


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

示例1: cleanOnlineInfo

bool IOPlayer::cleanOnlineInfo()
{
	DatabaseDriver* db = DatabaseDriver::instance();
	DBQuery query;
	query << "UPDATE `players` SET `online` = 0 WHERE `world_id` = " << g_config.getNumber(ConfigManager::WORLD_ID);
	return db->executeQuery(query);
}
开发者ID:Pietia10,项目名称:server,代码行数:7,代码来源:ioplayer.cpp

示例2: saveAccount

bool IOAccount::saveAccount(const Account& acc)
{
	DatabaseDriver* db = DatabaseDriver::instance();
	DBQuery query;

	query << "UPDATE `accounts` SET `premend` = " << acc.premiumEnd << ", `warnings` = " << acc.warnings << " WHERE `id` = " << acc.number;
	return db->executeQuery(query);
}
开发者ID:HeavenIsLost,项目名称:server,代码行数:8,代码来源:ioaccount.cpp

示例3: updateLogoutInfo

void IOPlayer::updateLogoutInfo(Player* player)
{
	DatabaseDriver* db = DatabaseDriver::instance();
	DBQuery query;

	query << "UPDATE `players` SET `lastlogout` = " << player->lastLogout
			<< ", `online` = 0"
			<< " WHERE `id` = " << player->getGUID();

	db->executeQuery(query);
}
开发者ID:Pietia10,项目名称:server,代码行数:11,代码来源:ioplayer.cpp

示例4: savePlayer

bool IOPlayer::savePlayer(Player* player, bool shallow)
{
	player->preSave();

	DatabaseDriver* db = DatabaseDriver::instance();
	DBQuery query;
	DBResult_ptr result;

	//check if the player has to be saved or not
	query << "SELECT `save` FROM `players` WHERE `id` = " << player->getGUID();
	if(!(result = db->storeQuery(query))){
		return false;
	}

	const uint32_t save = result->getDataInt("save");

	if(save == 0)
		return true;

	//serialize conditions
	PropWriteStream propWriteStream;
	for(ConditionList::const_iterator it = player->conditions.begin(); it != player->conditions.end(); ++it){
		if((*it)->isPersistent()){
			if(!(*it)->serialize(propWriteStream)){
				return false;
			}

			propWriteStream.ADD_UCHAR(*CONDITIONATTR_END);
		}
	}

	uint32_t conditionsSize;
	const char* conditions = propWriteStream.getStream(conditionsSize);

	//First, an UPDATE query to write the player itself
	query.reset();
	query << "UPDATE `players` SET `level` = " << player->level
	<< ", `vocation` = " << (int32_t)player->getVocationId()
	<< ", `health` = " << player->health
	<< ", `healthmax` = " << player->healthMax
	<< ", `direction` = " << player->getDirection().value()
	<< ", `experience` = " << player->experience
	<< ", `lookbody` = " << (int32_t)player->defaultOutfit.lookBody
	<< ", `lookfeet` = " << (int32_t)player->defaultOutfit.lookFeet
	<< ", `lookhead` = " << (int32_t)player->defaultOutfit.lookHead
	<< ", `looklegs` = " << (int32_t)player->defaultOutfit.lookLegs
	<< ", `looktype` = " << (int32_t)player->defaultOutfit.lookType
	<< ", `lookaddons` = " << (int32_t)player->defaultOutfit.lookAddons
	<< ", `maglevel` = " << player->magLevel
	<< ", `mana` = " << player->mana
	<< ", `manamax` = " << player->manaMax
	<< ", `manaspent` = " << player->manaSpent
	<< ", `soul` = " << player->soul
	<< ", `town_id` = " << player->town
	<< ", `posx` = " << player->getLoginPosition().x
	<< ", `posy` = " << player->getLoginPosition().y
	<< ", `posz` = " << player->getLoginPosition().z
	<< ", `cap` = " << player->getCapacity()
	<< ", `sex` = " << player->sex.value()
	<< ", `conditions` = " << db->escapeBlob(conditions, conditionsSize)
	<< ", `loss_experience` = " << (int32_t)player->getLossPercent(LOSS_EXPERIENCE)
	<< ", `loss_mana` = " << (int32_t)player->getLossPercent(LOSS_MANASPENT)
	<< ", `loss_skills` = " << (int32_t)player->getLossPercent(LOSS_SKILLTRIES)
	<< ", `loss_items` = " << (int32_t)player->getLossPercent(LOSS_ITEMS)
	<< ", `loss_containers` = " << (int32_t)player->getLossPercent(LOSS_CONTAINERS)
	<< ", `stamina` = " << player->stamina;

#ifdef __SKULLSYSTEM__
	query << ", `skull_type` = " << (player->getSkull() == SKULL_RED || player->getSkull() == SKULL_BLACK ? player->getSkull().value() : 0);
	query << ", `skull_time` = " << player->lastSkullTime;
#endif

	query << " WHERE `id` = " << player->getGUID();

	DBTransaction transaction(db);
	if(!transaction.begin())
		return false;

	if(!db->executeQuery(query)){
		return false;
	}

	//skills
	for(int32_t i = 0; i <= 6; i++){
		query.reset();
		query << "UPDATE `player_skills` SET `value` = " << player->skills[i][SKILL_LEVEL] << ", `count` = " << player->skills[i][SKILL_TRIES] << " WHERE `player_id` = " << player->getGUID() << " AND `skill_id` = " << i;

		if(!db->executeQuery(query)){
			return false;
		}
	}

	if(shallow)
		return transaction.commit();

	// deletes all player-related stuff

	/*
	query << "DELETE FROM `player_items` WHERE `player_id` = " << player->getGUID();

//.........这里部分代码省略.........
开发者ID:Pietia10,项目名称:server,代码行数:101,代码来源:ioplayer.cpp


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