summaryrefslogtreecommitdiff
path: root/libpqpp/modifycommand.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-12-07 14:26:09 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2015-12-07 14:26:09 +0000
commitb58f541a17dcc3eadb0502275bc90412ed9115a7 (patch)
treedb9175af481bc36eee961b9a7182e9a11dc58590 /libpqpp/modifycommand.cpp
parentImprove connection failure detection (diff)
downloadlibdbpp-postgresql-b58f541a17dcc3eadb0502275bc90412ed9115a7.tar.bz2
libdbpp-postgresql-b58f541a17dcc3eadb0502275bc90412ed9115a7.tar.xz
libdbpp-postgresql-b58f541a17dcc3eadb0502275bc90412ed9115a7.zip
Merge select and modify command's SQL parser
Diffstat (limited to 'libpqpp/modifycommand.cpp')
-rw-r--r--libpqpp/modifycommand.cpp17
1 files changed, 1 insertions, 16 deletions
diff --git a/libpqpp/modifycommand.cpp b/libpqpp/modifycommand.cpp
index 3eb41ec..460ec31 100644
--- a/libpqpp/modifycommand.cpp
+++ b/libpqpp/modifycommand.cpp
@@ -21,22 +21,7 @@ PQ::ModifyCommand::prepare() const
if (!prepared) {
std::string psql;
psql.reserve(sql.length() + 20);
- 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;
- }
- }
+ prepareSql(psql, sql);
c->checkResultFree(PQprepare(
c->conn, stmntName.c_str(), psql.c_str(), values.size(), NULL), PGRES_COMMAND_OK);
prepared = true;