mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-22 11:11:30 +00:00
Merge pull request #192 from addtheice/RunQueryToDatabaseQuery_EQW
Run query to database query eqw
This commit is contained in:
commit
d5a5635a14
@ -384,72 +384,57 @@ bool EQW::SetPublicNote(uint32 charid, const char *note) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int EQW::CountBugs() {
|
int EQW::CountBugs() {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string query = "SELECT count(*) FROM bugs where status = 0";
|
||||||
char* query = 0;
|
auto results = database.QueryDatabase(query);
|
||||||
MYSQL_RES *result;
|
if (!results.Success())
|
||||||
MYSQL_ROW row;
|
return 0;
|
||||||
if(database.RunQuery(query, MakeAnyLenString(&query, "SELECT count(*) FROM bugs where status = 0"), errbuf, &result)) {
|
|
||||||
safe_delete_array(query);
|
if (results.RowCount() == 0)
|
||||||
if((row = mysql_fetch_row(result))) {
|
return 0;
|
||||||
int count = atoi(row[0]);
|
|
||||||
mysql_free_result(result);
|
auto row = results.begin();
|
||||||
return count;
|
return atoi(row[0]);
|
||||||
}
|
|
||||||
mysql_free_result(result);
|
|
||||||
}
|
|
||||||
safe_delete_array(query);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> EQW::ListBugs(uint32 offset) {
|
std::vector<std::string> EQW::ListBugs(uint32 offset) {
|
||||||
std::vector<std::string> res;
|
std::vector<std::string> res;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string query = StringFormat("SELECT id FROM bugs WHERE status = 0 limit %d, 30", offset);
|
||||||
char* query = 0;
|
auto results = database.QueryDatabase(query);
|
||||||
MYSQL_RES *result;
|
|
||||||
MYSQL_ROW row;
|
if (!results.Success())
|
||||||
if(database.RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM bugs WHERE status = 0 limit %d, 30", offset), errbuf, &result)) {
|
return res;
|
||||||
safe_delete_array(query);
|
|
||||||
while((row = mysql_fetch_row(result))) {
|
for (auto row = results.begin();row != results.end(); ++row)
|
||||||
res.push_back(row[0]);
|
res.push_back(row[0]);
|
||||||
}
|
|
||||||
mysql_free_result(result);
|
|
||||||
}
|
|
||||||
safe_delete_array(query);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EQW::ResolveBug(const char *id) {
|
void EQW::ResolveBug(const char *id) {
|
||||||
std::vector<std::string> res;
|
std::vector<std::string> res;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string query = StringFormat("UPDATE bugs SET status=1 WHERE id=%s", id);
|
||||||
char* query = 0;
|
database.QueryDatabase(query);
|
||||||
if(database.RunQuery(query, MakeAnyLenString(&query, "UPDATE bugs SET status=1 WHERE id=%s", id), errbuf)) {
|
|
||||||
safe_delete_array(query);
|
|
||||||
}
|
|
||||||
safe_delete_array(query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EQW::SendMessage(uint32 type, const char *msg) {
|
void EQW::SendMessage(uint32 type, const char *msg) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user