mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-10 10:12:24 +00:00
GetAccountIDFromLSID converted to QueryDatabase
This commit is contained in:
parent
20e40a9a9c
commit
e20e5e59b8
@ -1352,38 +1352,31 @@ bool Database::AddToNameFilter(const char* name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 Database::GetAccountIDFromLSID(uint32 iLSID, char* oAccountName, int16* oStatus) {
|
uint32 Database::GetAccountIDFromLSID(uint32 iLSID, char* oAccountName, int16* oStatus) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
char *query = nullptr;
|
||||||
char *query = 0;
|
|
||||||
MYSQL_RES *result;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
|
|
||||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT id, name, status FROM account WHERE lsaccount_id=%i", iLSID), errbuf, &result))
|
auto results = QueryDatabase(query, MakeAnyLenString(&query, "SELECT id, name, status FROM account WHERE lsaccount_id=%i", iLSID));
|
||||||
|
|
||||||
|
if (!results.Success())
|
||||||
{
|
{
|
||||||
safe_delete_array(query);
|
std::cerr << "Error in GetAccountIDFromLSID query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||||
if (mysql_num_rows(result) == 1) {
|
|
||||||
row = mysql_fetch_row(result);
|
|
||||||
uint32 account_id = atoi(row[0]);
|
|
||||||
if (oAccountName)
|
|
||||||
strcpy(oAccountName, row[1]);
|
|
||||||
if (oStatus)
|
|
||||||
*oStatus = atoi(row[2]);
|
|
||||||
mysql_free_result(result);
|
|
||||||
return account_id;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mysql_free_result(result);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
mysql_free_result(result);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
std::cerr << "Error in GetAccountIDFromLSID query '" << query << "' " << errbuf << std::endl;
|
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
safe_delete_array(query);
|
||||||
|
|
||||||
return 0;
|
if (results.RowCount() != 1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
|
||||||
|
uint32 account_id = atoi(row[0]);
|
||||||
|
|
||||||
|
if (oAccountName)
|
||||||
|
strcpy(oAccountName, row[1]);
|
||||||
|
if (oStatus)
|
||||||
|
*oStatus = atoi(row[2]);
|
||||||
|
|
||||||
|
return account_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus) {
|
void Database::GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user