summaryrefslogtreecommitdiff
path: root/libpqpp/command.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libpqpp/command.cpp')
-rw-r--r--libpqpp/command.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/libpqpp/command.cpp b/libpqpp/command.cpp
index ba12574..94079da 100644
--- a/libpqpp/command.cpp
+++ b/libpqpp/command.cpp
@@ -25,6 +25,27 @@ PQ::Command::~Command()
}
void
+PQ::Command::prepareSql(std::string & psql, const std::string & sql)
+{
+ char buf[4];
+ int p = 1;
+ bool inquote = false;
+ for(std::string::const_iterator i = sql.begin(); i != sql.end(); ++i) {
+ if (*i == '?' && !inquote) {
+ snprintf(buf, 4, "$%d", p++);
+ psql += buf;
+ }
+ else if (*i == '\'') {
+ inquote = !inquote;
+ psql += *i;
+ }
+ else {
+ psql += *i;
+ }
+ }
+}
+
+void
PQ::Command::paramsAtLeast(unsigned int n)
{
if (values.size() <= n) {