ExportSpells converted to QueryDatabase

This commit is contained in:
Arthur Ice 2014-08-18 13:30:55 -07:00
parent 87efd22394
commit 11c327e1d7

View File

@ -32,7 +32,7 @@ void ExportBaseData(SharedDatabase *db);
int main(int argc, char **argv) { int main(int argc, char **argv) {
RegisterExecutablePlatform(ExePlatformClientExport); RegisterExecutablePlatform(ExePlatformClientExport);
set_exception_handler(); set_exception_handler();
LogFile->write(EQEMuLog::Status, "Client Files Export Utility"); LogFile->write(EQEMuLog::Status, "Client Files Export Utility");
if(!EQEmuConfig::LoadConfig()) { if(!EQEmuConfig::LoadConfig()) {
LogFile->write(EQEMuLog::Error, "Unable to load configuration file."); LogFile->write(EQEMuLog::Error, "Unable to load configuration file.");
@ -52,11 +52,11 @@ int main(int argc, char **argv) {
"database connection"); "database connection");
return 1; return 1;
} }
ExportSpells(&database); ExportSpells(&database);
ExportSkillCaps(&database); ExportSkillCaps(&database);
ExportBaseData(&database); ExportBaseData(&database);
return 0; return 0;
} }
@ -69,29 +69,27 @@ void ExportSpells(SharedDatabase *db) {
return; return;
} }
char errbuf[MYSQL_ERRMSG_SIZE]; const std::string query = "SELECT * FROM spells_new ORDER BY id";
const char *query = "SELECT * FROM spells_new ORDER BY id"; auto results = db->QueryDatabase(query);
MYSQL_RES *result;
MYSQL_ROW row; if(results.Success()) {
if(db->RunQuery(query, strlen(query), errbuf, &result)) { for (auto row = results.begin(); row != results.end(); ++row) {
while(row = mysql_fetch_row(result)) {
std::string line; std::string line;
unsigned int fields = mysql_num_fields(result); unsigned int fields = results.ColumnCount();
for(unsigned int i = 0; i < fields; ++i) { for(unsigned int i = 0; i < fields; ++i) {
if(i != 0) { if(i != 0) {
line.push_back('^'); line.push_back('^');
} }
line += row[i]; line += row[i];
} }
fprintf(f, "%s\n", line.c_str()); fprintf(f, "%s\n", line.c_str());
} }
mysql_free_result(result);
} else { } else {
LogFile->write(EQEMuLog::Error, "Error in ExportSpells query '%s' %s", query, errbuf); LogFile->write(EQEMuLog::Error, "Error in ExportSpells query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
} }
fclose(f); fclose(f);
} }