summaryrefslogtreecommitdiff
path: root/server/src/pracrodaopgsql.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/pracrodaopgsql.cc')
-rw-r--r--server/src/pracrodaopgsql.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/server/src/pracrodaopgsql.cc b/server/src/pracrodaopgsql.cc
index 683fe85..7159b03 100644
--- a/server/src/pracrodaopgsql.cc
+++ b/server/src/pracrodaopgsql.cc
@@ -244,10 +244,37 @@ unsigned PracroDAOPgsql::nrOfCommits(std::string patientid, std::string macronam
void PracroDAOPgsql::addFieldname(std::string name, std::string description)
{
+ std::stringstream timestamp; timestamp << time(NULL);
+ std::string ts;
+ try {
+ pqxx::work W(*conn);
+ ts = "INSERT INTO fieldnames (name, description, \"timestamp\") VALUES ("
+ " '" + W.esc(name) + "', "
+ " '" + W.esc(description) + "', "
+ " '" + W.esc(timestamp.str()) + "' "
+ ")"
+ ;
+ PRACRO_DEBUG(sql, "Query: %s\n", ts.c_str());
+ pqxx::result R = W.exec(ts);
+ W.commit();
+ } catch (std::exception &e) {
+ PRACRO_ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
+ }
}
void PracroDAOPgsql::delFieldname(std::string name)
{
+ std::string ts;
+ try {
+ pqxx::work W(*conn);
+ ts = "DELETE FROM fieldnames WHERE name="
+ "'" + W.esc(name) + "' ";
+ PRACRO_DEBUG(sql, "Query: %s\n", ts.c_str());
+ pqxx::result R = W.exec(ts);
+ W.commit();
+ } catch (std::exception &e) {
+ PRACRO_ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
+ }
}
std::vector<Fieldname> PracroDAOPgsql::getFieldnames()