void QGlobalCache::LoadBy(const std::string &query) { auto results = database.QueryDatabase(query); if (!results.Success()) return; for (auto row = results.begin(); row != results.end(); ++row) AddGlobal(0, QGlobal(row[0], atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5] ? atoi(row[5]) : 0xFFFFFFFF)); }
void QGlobalCache::LoadByCharID(uint32 charID) { char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; MYSQL_RES *result; MYSQL_ROW row; if (database.RunQuery(query, MakeAnyLenString(&query, "select id, name, charid, npcid, zoneid, value, expdate from" " quest_globals where charid = %d && npcid = 0", charID), errbuf, &result)) { while((row = mysql_fetch_row(result))) { AddGlobal(atoi(row[0]), QGlobal(std::string(row[1]), atoi(row[2]), atoi(row[3]), atoi(row[4]), row[5], row[6]?atoi(row[6]):0xFFFFFFFF)); } mysql_free_result(result); } safe_delete_array(query); }