added better database get api
This commit is contained in:
@@ -41,13 +41,13 @@ bool initDb() {
|
||||
}
|
||||
|
||||
int64_t getKeyOfCharacter(const string& name){
|
||||
auto sql = format("SELECT id FROM shadowrun_characters WHERE name = '{}' LIMIT 1;", name);
|
||||
std::string sql = "SELECT id FROM shadowrun_characters WHERE name = ? LIMIT 1;";
|
||||
auto db = Database();
|
||||
|
||||
if (!db.open())
|
||||
return -1;
|
||||
|
||||
auto opt_int = db.getInt(sql.c_str());
|
||||
auto opt_int = db.get<int>(sql, {name});
|
||||
if (opt_int.has_value()) {
|
||||
return opt_int.value();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user