游戏服务器之存储过程查询
来源:互联网 发布:软件测试网络培训班 编辑:程序博客网 时间:2024/05/18 01:09
以检查账号和密码为例,说明存储过程在游戏服务器中查询的使用。查询执行的处理是在单独的线程里处理(账号管理线程),返回是通过队列方式异步返回。
存储过程函数proc_validateuserlogin
begindeclare nUserId bigint default null;declare sUserPswd varchar(48) default null;#根据账号id,从users表查询用户id和密码 (sAccount,sPswd是存入的函数存数)select userid, passwd into nUserId, sUserPswd from users where account = sAccount;if nUserId is null thenselect 1, 0;#返回1,0,表示用户不存在else if sUserPswd != sPswd thenselect 2, 0;#返回2,0,表示密码错误 elseselect 0, nUserId;#返回0,用户id end if;end if;end
参数(账号、密码):
in sAccount varchar(32), in sPswd varchar(48)
检查查询请求
void CAccountManager::ValidateLoginRequest(const LoginRequest *pRequest){//数据库未就绪if (!m_AccountSQL.Connected()){ResultLoginRequest(pRequest, -1, 0);//返回消息return;}//数据库查询错误(1)if (m_AccountSQL.Query("call proc_validateuserlogin(\"%s\", \"%s\")", pRequest->sAccount, pRequest->sPasswd)){ResultLoginRequest(pRequest, -2, 0);return;}do{//数据库查询错误(2)MYSQL_ROW pRow = m_AccountSQL.CurrentRow();if (!pRow || m_AccountSQL.GetFieldCount() < 2){ResultLoginRequest(pRequest, -3, 0);break;}int nErrorCode = -100;int nUserId = 0;sscanf(pRow[0], "%d", &nErrorCode);sscanf(pRow[1], "%d", &nUserId);if (nErrorCode != 0 || nUserId == 0){//用户不存在if (nErrorCode == 1){ResultLoginRequest(pRequest, -4, 0);break;}//密码错误if (nErrorCode == 2){ResultLoginRequest(pRequest, -5, 0);break;}//未知的数据库错误码ResultLoginRequest(pRequest, -6, 0);}ResultLoginRequest(pRequest, 0, nUserId);}while (0);m_AccountSQL.ResetQuery();}
其中:
CMySQLConenction m_AccountSQL;//mysql数据连接类
0 0
- 游戏服务器之存储过程查询
- SQL之通用查询分页存储过程
- SQL之通用查询分页存储过程
- 报表查询之存储过程细节要点
- 存储过程--插入--查询
- Oracle 查询存储过程
- 分页查询存储过程
- 存储过程模糊查询~
- 查询参数存储过程
- 分页查询存储过程
- kettle 查询 存储过程
- mysq 存储过程查询
- 存储过程 查询
- 存储过程分页查询
- 模糊查询存储过程
- 存储过程条件查询
- SQL之根据表名动态查询的存储过程
- 通用存储过程之三:根据主键的值,查询记录的存储过程
- VS2010 向前定位,向后定位 界面上的按钮
- UISearchBar的使用以及下拉列表框的实现
- 代码编辑器Sublime Text2
- Hadoop中CombineFileInputFormat详解
- 大规模or这件,了,倒
- 游戏服务器之存储过程查询
- java 学习写架构必会几大技术点
- Https简单原理
- <many-to-one>设置
- 返屏秆脊考颊断自街姑猿控讨昂嘲
- ADT 14 之后case语句报错
- myeclipse在retina里模糊问题的解决方案
- 登山的程序员 - 反思极限编程之“原代码就是设计”
- 整理:matlab的fopen