From e360ba520931a2e44428b427459cf615c9630267 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 12:35:16 -0700 Subject: [PATCH] Store converted to QueryDatabase --- common/ptimer.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/common/ptimer.cpp b/common/ptimer.cpp index bfca79452..c099832ed 100644 --- a/common/ptimer.cpp +++ b/common/ptimer.cpp @@ -156,32 +156,26 @@ bool PersistentTimer::Load(Database *db) { bool PersistentTimer::Store(Database *db) { if(Expired(db, false)) //dont need to store expired timers. - return(true); - - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - uint32 qlen = 0; - - qlen = MakeAnyLenString(&query, "REPLACE INTO timers " - " (char_id,type,start,duration,enable) " - " VALUES(%lu,%u,%lu,%lu,%d)", - (unsigned long)_char_id, _type, (unsigned long)start_time, (unsigned long)timer_time, enabled?1:0); + return true; + std::string query = StringFormat("REPLACE INTO timers " + " (char_id, type, start, duration, enable) " + " VALUES (%lu, %u, %lu, %lu, %d)", + (unsigned long)_char_id, _type, (unsigned long)start_time, + (unsigned long)timer_time, enabled ? 1: 0); #ifdef DEBUG_PTIMERS - printf("Storing timer: char %lu of type %u: '%s'\n", (unsigned long)_char_id, _type, query); + printf("Storing timer: char %lu of type %u: '%s'\n", (unsigned long)_char_id, _type, query.c_str()); #endif - - if (!db->RunQuery(query, qlen, errbuf)) { - safe_delete_array(query); + auto results = db->QueryDatabase(query); + if (!results.Success()) { #if EQDEBUG > 5 - LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Store, error: %s", errbuf); + LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Store, error: %s", results.ErrorMessage().c_str()); #endif - return(false); + return false; } - safe_delete_array(query); - return(true); + return true; } bool PersistentTimer::Clear(Database *db) {