diff options
author | louiz’ <louiz@louiz.org> | 2017-10-04 21:28:18 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2017-12-02 20:08:47 +0100 |
commit | 0168b96b79db2627fdba77a8712956408aa081d1 (patch) | |
tree | 5591527ed8a04be8ea04c49521d9e9c868677bd1 /src/database/query.cpp | |
parent | 5b27cee97272d4ae6ff30f03dc57221fa3e3183f (diff) | |
download | biboumi-0168b96b79db2627fdba77a8712956408aa081d1.tar.gz biboumi-0168b96b79db2627fdba77a8712956408aa081d1.tar.bz2 biboumi-0168b96b79db2627fdba77a8712956408aa081d1.tar.xz biboumi-0168b96b79db2627fdba77a8712956408aa081d1.zip |
Add postgresql support
Diffstat (limited to 'src/database/query.cpp')
-rw-r--r-- | src/database/query.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/database/query.cpp b/src/database/query.cpp index ba63a92..6f305b2 100644 --- a/src/database/query.cpp +++ b/src/database/query.cpp @@ -1,9 +1,29 @@ #include <database/query.hpp> #include <database/column.hpp> -template <> -void add_param<Id>(Query&, const Id&) -{} +void actual_bind(Statement& statement, const std::string& value, int index) +{ + log_debug("binding string:", value, " to col ", index); + statement.bind_text(index, value); +} + +void actual_bind(Statement& statement, const std::size_t value, int index) +{ + log_debug("binding size_t:", value); + statement.bind_int64(index, value); +} + +void actual_bind(Statement& statement, const OptionalBool& value, int index) +{ + log_debug("binding optional_t:", value.to_string()); + if (!value.is_set) + statement.bind_int64(index, 0); + else if (value.value) + statement.bind_int64(index, 1); + else + statement.bind_int64(index, -1); +} + void actual_add_param(Query& query, const std::string& val) { @@ -28,7 +48,8 @@ Query& operator<<(Query& query, const char* str) Query& operator<<(Query& query, const std::string& str) { - query.body += "?"; + query.body += "$" + std::to_string(query.current_param); + query.current_param++; actual_add_param(query, str); return query; } |