GetBugDetails converted to QueryDatabase

This commit is contained in:
Arthur Ice 2014-08-18 16:15:47 -07:00
parent 34f051ab9a
commit 9270c45a5e

View File

@ -412,25 +412,22 @@ std::vector<std::string> EQW::ListBugs(uint32 offset) {
std::map<std::string,std::string> EQW::GetBugDetails(Const_char *id) { std::map<std::string,std::string> EQW::GetBugDetails(Const_char *id) {
std::map<std::string,std::string> res; std::map<std::string,std::string> res;
char errbuf[MYSQL_ERRMSG_SIZE]; std::string query = StringFormat("SELECT name, zone, x, y, z, target, bug FROM bugs WHERE id = %s", id);
char* query = 0; auto results = database.QueryDatabase(query);
MYSQL_RES *result;
MYSQL_ROW row; if (!results.Success())
if(database.RunQuery(query, MakeAnyLenString(&query, "select name, zone, x, y, z, target, bug from bugs where id = %s", id), errbuf, &result)) { return res;
safe_delete_array(query);
while((row = mysql_fetch_row(result))) { for(auto row = results.begin(); row != results.end(); ++row) {
res["name"] = row[0]; res["name"] = row[0];
res["zone"] = row[1]; res["zone"] = row[1];
res["x"] = row[2]; res["x"] = row[2];
res["y"] = row[3]; res["y"] = row[3];
res["z"] = row[4]; res["z"] = row[4];
res["target"] = row[5]; res["target"] = row[5];
res["bug"] = row[6]; res["bug"] = row[6];
res["id"] = id; res["id"] = id;
} }
mysql_free_result(result);
}
safe_delete_array(query);
return res; return res;
} }