mirror of
https://github.com/EQEmu/Server.git
synced 2026-02-22 18:52:26 +00:00
CreateAccount converted to QueryDatabase
This commit is contained in:
parent
95c82d9968
commit
0ab8c2481b
@ -307,30 +307,34 @@ int16 Database::CheckStatus(uint32 account_id)
|
||||
}
|
||||
|
||||
uint32 Database::CreateAccount(const char* name, const char* password, int16 status, uint32 lsaccount_id) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
uint32 querylen;
|
||||
uint32 last_insert_id;
|
||||
char *query = nullptr;
|
||||
|
||||
uint32 queryLen;
|
||||
|
||||
if (password)
|
||||
querylen = MakeAnyLenString(&query, "INSERT INTO account SET name='%s', password='%s', status=%i, lsaccount_id=%i, time_creation=UNIX_TIMESTAMP();",name,password,status, lsaccount_id);
|
||||
queryLen = MakeAnyLenString(&query, "INSERT INTO account SET name='%s', password='%s', status=%i, lsaccount_id=%i, time_creation=UNIX_TIMESTAMP();",name,password,status, lsaccount_id);
|
||||
else
|
||||
querylen = MakeAnyLenString(&query, "INSERT INTO account SET name='%s', status=%i, lsaccount_id=%i, time_creation=UNIX_TIMESTAMP();",name, status, lsaccount_id);
|
||||
queryLen = MakeAnyLenString(&query, "INSERT INTO account SET name='%s', status=%i, lsaccount_id=%i, time_creation=UNIX_TIMESTAMP();",name, status, lsaccount_id);
|
||||
|
||||
std::cerr << "Account Attempting to be created:" << name << " " << (int16) status << std::endl;
|
||||
if (!RunQuery(query, querylen, errbuf, 0, 0, &last_insert_id)) {
|
||||
std::cerr << "Error in CreateAccount query '" << query << "' " << errbuf << std::endl;
|
||||
|
||||
auto results = QueryDatabase(query, queryLen);
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in CreateAccount query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
safe_delete_array(query);
|
||||
return 0;
|
||||
}
|
||||
safe_delete_array(query);
|
||||
|
||||
if (last_insert_id == 0) {
|
||||
std::cerr << "Error in CreateAccount query '" << query << "' " << errbuf << std::endl;
|
||||
if (results.LastInsertedID() == 0)
|
||||
{
|
||||
std::cerr << "Error in CreateAccount query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
safe_delete_array(query);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return last_insert_id;
|
||||
return results.LastInsertedID();
|
||||
}
|
||||
|
||||
bool Database::DeleteAccount(const char* name) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user