summaryrefslogtreecommitdiff
path: root/server/src/database.cc
diff options
context:
space:
mode:
authordeva <deva>2007-10-01 15:18:21 +0000
committerdeva <deva>2007-10-01 15:18:21 +0000
commitc09b06d5e765955ea41c6b02891390ed6a714e55 (patch)
treeb90a1a919fd086146256a4ef5ecc44faa2dd5c51 /server/src/database.cc
parent1890cff193f6e5c10c7581b0767bbb5ac91f8cc7 (diff)
Now the resume is generated using a format string.
Diffstat (limited to 'server/src/database.cc')
-rw-r--r--server/src/database.cc62
1 files changed, 29 insertions, 33 deletions
diff --git a/server/src/database.cc b/server/src/database.cc
index 1a48925..ad6bbe0 100644
--- a/server/src/database.cc
+++ b/server/src/database.cc
@@ -26,9 +26,8 @@
*/
#include "database.h"
-#include "tostring.h"
+//#include "tostring.h"
#include "uid.h"
-#include <time.h>
Database::Database(std::string hostname, std::string user, std::string password)
: c("host=" + hostname +
@@ -42,47 +41,44 @@ Database::~Database()
{
}
-int Database::post(Transaction &transaction)
+int Database::post(std::string &user, std::string &cpr, std::string &time, Commit &commit)
{
UID uid;
- std::string now = toString((unsigned int)time(NULL));
try {
pqxx::work W(c);
- Commits::iterator i = transaction.commits.begin();
- while(i != transaction.commits.end()) {
- Commit &commit = *i;
- // std::string transid = transidbase + toString(idx);
-
- // Insert transaction entry
- std::string sql = "INSERT INTO transactions VALUES('" +
- transaction.cpr + "', '" +
+ // std::string transid = transidbase + toString(idx);
+
+ // Insert transaction entry
+ std::string sql = "INSERT INTO transactions VALUES('" +
+ cpr + "', '" +
+ uid.toString() + "', '" +
+ commit.macro + "', '" +
+ commit.version + "', '" +
+ time + "', '" +
+ user + "')";
+ W.exec(sql);
+
+ // Insert field entries
+ Fields::iterator j = commit.fields.begin();
+ while(j != commit.fields.end()) {
+ // std::string name = j->first;
+ // std::string value = j->second;
+
+ sql = "INSERT INTO fields VALUES('" +
uid.toString() + "', '" +
- commit.macro + "', '" +
- commit.version + "', '" +
- now + "', '" +
- transaction.user + "')";
+ j->first + "', '" +
+ j->second + "')";
+ // name + "', '" +
+ // value + "')";
W.exec(sql);
-
- // Insert field entries
- Fields::iterator j = commit.fields.begin();
- while(j != commit.fields.end()) {
- Field &field = *j;
-
- sql = "INSERT INTO fields VALUES('" +
- uid.toString() + "', '" +
- field.name + "', '" +
- field.value + "')";
- W.exec(sql);
-
- j++;
- }
-
- uid++;
- i++;
+
+ j++;
}
+ uid++;
+
W.commit();
} catch(const std::exception &e) {
// throw PostgreSQLException(e.what());