diff options
Diffstat (limited to 'server/src/database.cc')
-rw-r--r-- | server/src/database.cc | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/server/src/database.cc b/server/src/database.cc index 62454a2..35d9214 100644 --- a/server/src/database.cc +++ b/server/src/database.cc @@ -143,6 +143,29 @@ Values Database::getValues(std::string cpr, return values; } +bool Database::checkMacro(std::string cpr, + std::string macro, + time_t oldest) +{ + pqxx::work W(c); + + std::stringstream query; + query << "SELECT oid"; + query << " FROM transactions"; + query << " WHERE cpr = '" << cpr << "'"; + query << " AND macro = '" << macro << "'"; + query << " AND timestamp >= " << oldest; + query << " ORDER BY timestamp"; + + try { + pqxx::result R = W.exec(query.str()); + + return R.size() != 0; + } catch( ... ) { + return false; + } +} + /* -- As root: -- #createuser -P -h localhost -U postgres @@ -160,7 +183,7 @@ DROP TABLE transactions; CREATE TABLE transactions ( "cpr" varchar(11), - "makro" text, + "macro" text, "version" text, "timestamp" bigint, "user" text |