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


C++ Db::WriteDb方法代码示例

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


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

示例1: DoUserRegister

int Account::DoUserRegister(Register &register_,Db &db,int playerId){
	char sql[256];
	time_t now_time;
	now_time = time(NULL);
	
	int forbid_login_time = 0;

	char nick[48] = "\0";
	//nick.assign(register_.nick.name,register_.nick.len); 
	int a = register_.nick.len;
	memcpy(nick,register_.nick.name,register_.nick.len); 
 
	char phone[12] = "\0";
	//phone.assign(register_.phone,register_.phone_len); 
	memcpy(phone,register_.phone,register_.phone_len); 

	char address_1[512] = "\0";
	memcpy(address_1,register_.address1,register_.address1_len);

	char address_2[512] = "\0";
	memcpy(address_2,register_.address2,register_.address2_len);

	char address_3[512] = "\0";
	memcpy(address_3,register_.address3,register_.address3_len);

	sprintf_s(sql, "insert into playerInfo values(%d, \'%s\', %d, %d, %d, \'%s\', \'%s\', \'%s\', \'%s\');", playerId,nick,register_.age,int(now_time),forbid_login_time,phone,address_1,address_2,address_3);
	
	
	string sql_find_nick = "select player_id from playerInfo where nick = \'" + (string)nick + "\'";
	
	char sql_updatePlayerId[256];
	sprintf_s(sql_updatePlayerId,"update playerMaxId set player_max_id = %d",playerId);

	db.ReadDb(sql_find_nick);
	if (db.nRow == 1)
	{
		db.freeTableData();
		return kSameNick;
	}else{
		db.freeTableData();
		db.WriteDb(sql);
		db.WriteDb(sql_updatePlayerId);
	}
	return kSucess;
}
开发者ID:adocode,项目名称:GameServer,代码行数:45,代码来源:account.cpp

示例2: connectDb

void connectDb(Db &db){
	db.OpenDb();

	bool result = db.CreateTable("Create Table playerMaxId(player_max_id int)");
	if (result)
	{
		db.WriteDb("insert into playerMaxId values(0)");
		p::playerMaxId = 0;
	}else{
		bool result = db.ReadDb("select player_max_id from playerMaxId");
		if (result)
		{
			std::string str = db.pazResult[db.nCol];
			p::playerMaxId = std::atoi(str.c_str());
			db.freeTableData();
		}
	}
	
	db.CreateTable("create table playerInfo(player_id int primary key,nick varchar(18),age int,register_time int,forbid_login_time int,phone varchar(12),address1 varchar(512),address2 varchar(512),address3 varchar(512))");
}
开发者ID:adocode,项目名称:GameServer,代码行数:20,代码来源:mainServer.cpp


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