|
@@ -25,7 +25,7 @@ std::string valuesAsString(std::vector<std::string> values, size_t number_of_fie
|
|
|
int index = 1;
|
|
|
for (const auto &value : values) {
|
|
|
if (index % number_of_fields == 0) {
|
|
|
- value_string += value + "), (";
|
|
|
+ value_string += "(" + value + ")";
|
|
|
} else {
|
|
|
value_string += value + ",";
|
|
|
}
|
|
@@ -37,7 +37,7 @@ std::string valuesAsString(std::vector<std::string> values, size_t number_of_fie
|
|
|
}
|
|
|
|
|
|
std::string insertStatement(DatabaseQuery query) {
|
|
|
- return std::string{"INSERT INTO " + query.table + fieldsAsString(query.fields) + valuesAsString(query.values, query.fields.size())};
|
|
|
+ return std::string{"INSERT INTO " + query.table + fieldsAsString(query.fields) + " " + valuesAsString(query.values, query.fields.size())};
|
|
|
}
|
|
|
|
|
|
std::string selectStatement(DatabaseQuery query) {
|
|
@@ -58,6 +58,7 @@ bool DatabaseConnection::setConfig(DatabaseConfiguration config) {
|
|
|
pqxx::result DatabaseConnection::performInsert (DatabaseQuery query) {
|
|
|
pqxx::connection connection(getConnectionString().c_str());
|
|
|
pqxx::work worker(connection);
|
|
|
+ auto insert_statement = insertStatement(query);
|
|
|
pqxx::result pqxx_result = worker.exec(insertStatement(query));
|
|
|
worker.commit();
|
|
|
|