Add GetWhere and DeleteWhere repository methods

This commit is contained in:
Akkadius
2020-04-04 04:44:39 -05:00
parent 9faae00d15
commit 15c9b64120
164 changed files with 8806 additions and 594 deletions
+53 -1
View File
@@ -268,7 +268,7 @@ public:
return titles_entry;
}
titles_entry = InstanceListRepository::NewEntity();
titles_entry = TitlesRepository::NewEntity();
return titles_entry;
}
@@ -349,6 +349,58 @@ public:
return all_entries;
}
static std::vector<Titles> GetWhere(std::string where_filter)
{
std::vector<Titles> all_entries;
auto results = database.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Titles entry{};
entry.id = atoi(row[0]);
entry.skill_id = atoi(row[1]);
entry.min_skill_value = atoi(row[2]);
entry.max_skill_value = atoi(row[3]);
entry.min_aa_points = atoi(row[4]);
entry.max_aa_points = atoi(row[5]);
entry.class = atoi(row[6]);
entry.gender = atoi(row[7]);
entry.char_id = atoi(row[8]);
entry.status = atoi(row[9]);
entry.item_id = atoi(row[10]);
entry.prefix = row[11];
entry.suffix = row[12];
entry.title_set = atoi(row[13]);
all_entries.push_back(entry);
}
return all_entries;
}
static int DeleteWhere(std::string where_filter)
{
auto results = database.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
PrimaryKey(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
};
#endif //EQEMU_TITLES_REPOSITORY_H