本文整理汇总了C++中AccountID::iaccounttype方法的典型用法代码示例。如果您正苦于以下问题:C++ AccountID::iaccounttype方法的具体用法?C++ AccountID::iaccounttype怎么用?C++ AccountID::iaccounttype使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AccountID
的用法示例。
在下文中一共展示了AccountID::iaccounttype方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FetchAccountInfo
//拉取返回帐号详细信息
int CFetchAccountHandler::FetchAccountInfo(const AccountID& stAccountID, const std::string& strPassword, AccountDB_FetchAccount_Response& rstResp)
{
//设置连接的DB
const ONEACCOUNTDBINFO* pstDBConfig = (CAccountDBApp::m_stAccountDBConfigManager).GetOneAccountDBInfoByIndex(m_iThreadIdx);
if(!pstDBConfig)
{
TRACE_THREAD(m_iThreadIdx, "Failed to get account db config, index %d\n", m_iThreadIdx);
return -1;
}
int iRet = m_pDatabase->SetMysqlDBInfo(pstDBConfig->szDBHost, pstDBConfig->szUserName, pstDBConfig->szUserPasswd, pstDBConfig->szDBName);
if(iRet)
{
TRACE_THREAD(m_iThreadIdx, "Failed to set mysql db info, ret %d\n", iRet);
return iRet;
}
char* pszQueryString = m_szQueryString[m_iThreadIdx];
int iLength = SAFE_SPRINTF(pszQueryString, sizeof(m_szQueryString[m_iThreadIdx])-1, "select * from %s where accountID='%s' and accountType=%d",
MYSQL_ACCOUNTINFO_TABLE, stAccountID.straccount().c_str(), stAccountID.iaccounttype());
iRet = m_pDatabase->ExecuteRealQuery(pszQueryString, iLength, true);
if(iRet)
{
TRACE_THREAD(m_iThreadIdx, "Failed to execute sql query, ret %d\n", iRet);
return iRet;
}
//分析结果
int iRowNum = m_pDatabase->GetNumberRows();
if(iRowNum != 1)
{
TRACE_THREAD(m_iThreadIdx, "Wrong result, invalid rows %d, account %s\n", iRowNum, stAccountID.straccount().c_str());
return T_ACCOUNTDB_INVALID_RECORD;
}
MYSQL_ROW pstResult = NULL;
unsigned long* pLengths = NULL;
unsigned int uFields = 0;
iRet = m_pDatabase->FetchOneRow(pstResult, pLengths, uFields);
if(iRet)
{
TRACE_THREAD(m_iThreadIdx, "Failed to fetch rows, account %s, ret %d\n", stAccountID.straccount().c_str(), iRet);
return iRet;
}
//判断uFields是否相符
if(uFields != MYSQL_ACCOUNTINFO_FIELDS)
{
TRACE_THREAD(m_iThreadIdx, "Wrong result, real fields %u, needed %u\n", uFields, MYSQL_ACCOUNTINFO_FIELDS);
return T_ACCOUNTDB_INVALID_RECORD;
}
//字段3是password
std::string strDBPassword(pstResult[3], pLengths[3]);
//检查密码是否一致
if(strDBPassword.compare(strPassword) != 0)
{
return T_ACCOUNTDB_INVALID_RECORD;
}
//从结果中解析需要的字段
rstResp.mutable_staccountid()->CopyFrom(stAccountID);
//字段0是accountID, 字段1是accountType, 跳过
//字段2是uin
rstResp.set_uin(strtoul(pstResult[2],NULL,10));
//字段4是lastWorldID
rstResp.set_iworldid(atoi(pstResult[4]));
//字段5是activeState
rstResp.set_bisbinded(atoi(pstResult[5]));
return T_SERVER_SUCESS;
}