SQL: update comments with database layout

sql-rework
Tomasz Golinski 2020-09-14 19:33:26 +02:00
rodzic 5d65cbe6e6
commit 8eb613df36
1 zmienionych plików z 4 dodań i 4 usunięć

Wyświetl plik

@ -142,7 +142,7 @@ bool OCdb::parse_item(const json& j) {
} }
bool OCdb::update_cache(const json& j) { bool OCdb::update_cache(const json& j) {
// (code TEXT PRIMARY KEY, name TEXT, location TEXT, type TEXT, status INTEGER, size TEXT, difficulty REAL, terrain REAL, country TEXT, region TEXT, owner TEXT) // (code TEXT PRIMARY KEY, name TEXT, location TEXT, type TEXT, status INTEGER, size TEXT, difficulty INTEGER, terrain INTEGER, country TEXT, region TEXT, owner TEXT)
std::map<std::string, std::string> fields; std::map<std::string, std::string> fields;
std::map<std::string, short> fields2; std::map<std::string, short> fields2;
int res; int res;
@ -355,7 +355,7 @@ Caches OCdb::get_user_caches_not_found(const std::string& uuid) const {
Caches OCdb::get_user_caches(const std::string& uuid, __attribute__((unused)) int count) const { Caches OCdb::get_user_caches(const std::string& uuid, __attribute__((unused)) int count) const {
int res; int res;
//code TEXT PRIMARY KEY, name TEXT, location TEXT, type TEXT, status INTEGER, size TEXT, difficulty REAL, terrain REAL, country TEXT, region TEXT, owner TEXT) //code TEXT PRIMARY KEY, name TEXT, location TEXT, type TEXT, status INTEGER, size TEXT, difficulty INTEGER, terrain INTEGER, country TEXT, region TEXT, owner TEXT)
sql = "SELECT code, location, type, size, difficulty, terrain, country, region, owner, status, name FROM caches WHERE EXISTS (SELECT cache_code FROM logs WHERE cache_code = code AND type = 1 and user = ?);"; sql = "SELECT code, location, type, size, difficulty, terrain, country, region, owner, status, name FROM caches WHERE EXISTS (SELECT cache_code FROM logs WHERE cache_code = code AND type = 1 and user = ?);";
res = sqlite3_prepare_v2(db, sql.c_str(), sql.length() + 1, &stmt, NULL); res = sqlite3_prepare_v2(db, sql.c_str(), sql.length() + 1, &stmt, NULL);
@ -371,7 +371,7 @@ Caches OCdb::get_user_caches(const std::string& uuid, __attribute__((unused)) in
Caches OCdb::get_user_caches_owned(const std::string& uuid) const { Caches OCdb::get_user_caches_owned(const std::string& uuid) const {
int res; int res;
//code TEXT PRIMARY KEY, name TEXT, location TEXT, type TEXT, status TEXT, size TEXT, difficulty REAL, terrain REAL, country TEXT, region TEXT, owner TEXT) //code TEXT PRIMARY KEY, name TEXT, location TEXT, type TEXT, status TEXT, size TEXT, difficulty INTEGER, terrain INTEGER, country TEXT, region TEXT, owner TEXT)
sql = "SELECT code, location, type, size, difficulty, terrain, country, region, owner, status, name FROM caches WHERE owner = ?;"; sql = "SELECT code, location, type, size, difficulty, terrain, country, region, owner, status, name FROM caches WHERE owner = ?;";
res = sqlite3_prepare_v2(db, sql.c_str(), sql.length() + 1, &stmt, NULL); res = sqlite3_prepare_v2(db, sql.c_str(), sql.length() + 1, &stmt, NULL);
@ -447,7 +447,7 @@ std::map<std::string, int> OCdb::get_region_stats() {
"zachodniopomorskie" "zachodniopomorskie"
}; };
//code TEXT PRIMARY KEY, name TEXT, location TEXT, type TEXT, status INTEGER, size TEXT, difficulty REAL, terrain REAL, country TEXT, region TEXT, owner TEXT) //code TEXT PRIMARY KEY, name TEXT, location TEXT, type TEXT, status INTEGER, size TEXT, difficulty INTEGER, terrain INTEGER, country TEXT, region TEXT, owner TEXT)
sql = "SELECT COUNT(code) FROM caches WHERE status = "; sql = "SELECT COUNT(code) FROM caches WHERE status = ";
sql += ok; sql += ok;
sql += " AND region = ?;"; sql += " AND region = ?;";