command_listpetition converted to QueryDatabase

This commit is contained in:
Arthur Ice 2014-10-04 10:12:39 -07:00
parent 5f5fba1117
commit accedf7184

View File

@ -3373,23 +3373,20 @@ void command_motd(Client *c, const Seperator *sep)
void command_listpetition(Client *c, const Seperator *sep) void command_listpetition(Client *c, const Seperator *sep)
{ {
char errbuf[MYSQL_ERRMSG_SIZE]; std::string query = "SELECT petid, charname, accountname FROM petitions ORDER BY petid";
char *query = 0; auto results = database.QueryDatabase(query);
MYSQL_RES *result; if (!results.Success())
MYSQL_ROW row; return;
bool header = false;
if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT petid, charname, accountname from petitions order by petid"), errbuf, &result)) {
LogFile->write(EQEMuLog::Normal,"Petition list requested by %s", c->GetName()); LogFile->write(EQEMuLog::Normal,"Petition list requested by %s", c->GetName());
while ((row = mysql_fetch_row(result))) {
if(!header) { if (results.RowCount() == 0)
header = true; return;
c->Message(13," ID : Character Name , Account Name"); c->Message(13," ID : Character Name , Account Name");
}
for (auto row = results.begin(); row != results.end(); ++row)
c->Message(15, " %s: %s , %s ",row[0],row[1],row[2]); c->Message(15, " %s: %s , %s ",row[0],row[1],row[2]);
}
mysql_free_result(result);
}
safe_delete_array(query);
} }
void command_equipitem(Client *c, const Seperator *sep) void command_equipitem(Client *c, const Seperator *sep)