From e3de570f2939418a5f66915ddab467f32a948851 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Thu, 3 Jul 2014 16:08:28 -0700 Subject: [PATCH] SetAccountStatus converted to QueryDatabase --- common/database.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/common/database.cpp b/common/database.cpp index 373e7db3d..adfb2c51e 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -372,18 +372,19 @@ bool Database::SetLocalPassword(uint32 accid, const char* password) { } bool Database::SetAccountStatus(const char* name, int16 status) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - uint32 affected_rows = 0; + char *query = nullptr; std::cout << "Account being GM Flagged:" << name << ", Level: " << (int16) status << std::endl; - if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE account SET status=%i WHERE name='%s';", status, name), errbuf, 0, &affected_rows)) { - safe_delete_array(query); - return false; - } + + auto results = QueryDatabase(query, MakeAnyLenString(&query, "UPDATE account SET status=%i WHERE name='%s';", status, name)); + safe_delete_array(query); - if (affected_rows == 0) { + if (!results.Success()) + return false; + + if (results.RowsAffected() == 0) + { std::cout << "Account: " << name << " does not exist, therefore it cannot be flagged\n"; return false; }