Advertisement
Guest User

Untitled

a guest
May 28th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. AccountInfo MySQLGunzDB::GetAccountInfo(const char* username, const char* password)
  2. {
  3.     AccountInfo accountInfo;
  4.     try
  5.     {
  6.         mysqlpp::Query query = gunzconn.query();
  7.         query << "select aid, ugradeid, pgradeid from account where username=" << mysqlpp::quote << username
  8.             << "and password=md5(" << mysqlpp::quote << password << ") LIMIT 1";
  9.         mysqlpp::StoreQueryResult result = query.store();
  10.        
  11.         if (result.num_rows() < 1)
  12.         {
  13.             accountInfo.AccountId = -1;
  14.             return accountInfo;
  15.         }
  16.  
  17.         strcpy(accountInfo.AccountName, username);
  18.         accountInfo.AccountId = result[0]["aid"];
  19.         accountInfo.AccountAccess = result[0]["ugradeid"];
  20.         accountInfo.AccountPremium = result[0]["pgradeid"];
  21.         return accountInfo;
  22.     }
  23.     catch (mysqlpp::Exception e)
  24.     {
  25.         printf ("Error: %s\n", e.what());
  26.     }
  27.    
  28.     accountInfo.AccountId = -1;
  29.     return accountInfo;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement