mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-28 09:17:15 +00:00
Add GetWhere and DeleteWhere repository methods
This commit is contained in:
@@ -298,7 +298,7 @@ public:
|
||||
return account_entry;
|
||||
}
|
||||
|
||||
account_entry = InstanceListRepository::NewEntity();
|
||||
account_entry = AccountRepository::NewEntity();
|
||||
|
||||
return account_entry;
|
||||
}
|
||||
@@ -389,6 +389,63 @@ public:
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<Account> GetWhere(std::string where_filter)
|
||||
{
|
||||
std::vector<Account> 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) {
|
||||
Account entry{};
|
||||
|
||||
entry.id = atoi(row[0]);
|
||||
entry.name = row[1];
|
||||
entry.charname = row[2];
|
||||
entry.sharedplat = atoi(row[3]);
|
||||
entry.password = row[4];
|
||||
entry.status = atoi(row[5]);
|
||||
entry.ls_id = row[6];
|
||||
entry.lsaccount_id = atoi(row[7]);
|
||||
entry.gmspeed = atoi(row[8]);
|
||||
entry.revoked = atoi(row[9]);
|
||||
entry.karma = atoi(row[10]);
|
||||
entry.minilogin_ip = row[11];
|
||||
entry.hideme = atoi(row[12]);
|
||||
entry.rulesflag = atoi(row[13]);
|
||||
entry.suspendeduntil = row[14];
|
||||
entry.time_creation = atoi(row[15]);
|
||||
entry.expansion = atoi(row[16]);
|
||||
entry.ban_reason = row[17];
|
||||
entry.suspend_reason = row[18];
|
||||
|
||||
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_ACCOUNT_REPOSITORY_H
|
||||
|
||||
Reference in New Issue
Block a user