DBSetGuildChannel converted to QueryDatabase

This commit is contained in:
Arthur Ice 2014-08-17 11:50:10 -07:00
parent a701541fce
commit 553d12412b

View File

@ -712,33 +712,27 @@ bool BaseGuildManager::DBSetGuildChannel(uint32 GuildID, const char* Channel)
if(m_db == nullptr)
return(false);
std::map<uint32, GuildInfo *>::const_iterator res;
res = m_guilds.find(GuildID);
auto res = m_guilds.find(GuildID);
if(res == m_guilds.end())
return(false);
GuildInfo *info = res->second;
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
//escape our strings.
uint32 len = strlen(Channel);
char *esc = new char[len*2+1];
m_db->DoEscapeString(esc, Channel, len);
if (!m_db->RunQuery(query, MakeAnyLenString(&query, "UPDATE guilds SET channel='%s' WHERE id=%d", esc, GuildID), errbuf))
std::string query = StringFormat("UPDATE guilds SET channel='%s' WHERE id=%d", esc, GuildID);
auto results = m_db->QueryDatabase(query);
if (!results.Success())
{
_log(GUILDS__ERROR, "Error setting Channel for guild %d '%s': %s", GuildID, query, errbuf);
safe_delete_array(query);
_log(GUILDS__ERROR, "Error setting Channel for guild %d '%s': %s", GuildID, query.c_str(), results.ErrorMessage().c_str());
safe_delete_array(esc);
return(false);
}
safe_delete_array(query);
safe_delete_array(esc);
_log(GUILDS__DB, "Set Channel for guild %d in the database", GuildID);