summaryrefslogtreecommitdiff
path: root/server/src/database.cc
diff options
context:
space:
mode:
authordeva <deva>2008-08-08 09:23:03 +0000
committerdeva <deva>2008-08-08 09:23:03 +0000
commitb7be78948cad7629427fd19769ddcfdfea3fb666 (patch)
tree172c4f213ae481ffb80dd31c9dd45d52920e4d73 /server/src/database.cc
parent817402b5208b0dbc92a64ed094a936c56c8c1e49 (diff)
Added print debug configurable.
Diffstat (limited to 'server/src/database.cc')
-rw-r--r--server/src/database.cc23
1 files changed, 18 insertions, 5 deletions
diff --git a/server/src/database.cc b/server/src/database.cc
index 2b8b83c..96aa697 100644
--- a/server/src/database.cc
+++ b/server/src/database.cc
@@ -26,6 +26,8 @@
*/
#include "database.h"
+#include <config.h>
+
Database::Database(std::string hostname, std::string user, std::string password)
#ifndef WITHOUT_DB
: c("host=" + hostname + " user=" + user + " password=" + password + " dbname=pracro")
@@ -74,9 +76,12 @@ void Database::commit(std::string user,
oid << R.inserted_oid();
#else
oid << "###GENERATED_OID###";
- printf("%s\n", ts.c_str());
#endif/*WITHOUT_DB*/
+#ifdef WITH_DEBUG
+ printf("%s\n", ts.c_str());
+#endif/*WITH_DEBUG*/
+
std::map< std::string, std::string >::iterator i = fields.begin();
while(i != fields.end()) {
@@ -86,9 +91,11 @@ void Database::commit(std::string user,
#ifndef WITHOUT_DB
W.exec(fs);
-#else
- printf("%s\n", fs.c_str());
#endif/*WITHOUT_DB*/
+
+#ifdef WITH_DEBUG
+ printf("%s\n", fs.c_str());
+#endif/*WITH_DEBUG*/
i++;
}
@@ -158,9 +165,11 @@ Values Database::getValues(std::string cpr,
ri++;
}
-#else
- printf("%s\n", query.str().c_str());
#endif/*WITHOUT_DB*/
+
+#ifdef WITH_DEBUG
+ printf("%s\n", query.str().c_str());
+#endif/*WITH_DEBUG*/
return values;
}
@@ -181,6 +190,10 @@ bool Database::checkMacro(std::string cpr,
query << " AND timestamp >= " << oldest;
query << " ORDER BY timestamp";
+#ifdef WITH_DEBUG
+ printf("%s\n", query.str().c_str());
+#endif/*WITH_DEBUG*/
+
#ifndef WITHOUT_DB
try {
pqxx::result R = W.exec(query.str());