diff options
author | Dan Goodliffe <daniel.goodliffe@pressassociation.com> | 2017-01-03 15:03:05 +0000 |
---|---|---|
committer | Dan Goodliffe <daniel.goodliffe@pressassociation.com> | 2017-01-03 15:16:54 +0000 |
commit | 40772ae759fe26acc69bebefa0eda173dbd981e4 (patch) | |
tree | 7afa52df382f8e8ee091dbb7acafee175403c9fb /libpqpp/pq-selectbase.cpp | |
parent | Only set unlogged for mocked tables on server versions 9.5 and above (diff) | |
download | libdbpp-postgresql-40772ae759fe26acc69bebefa0eda173dbd981e4.tar.bz2 libdbpp-postgresql-40772ae759fe26acc69bebefa0eda173dbd981e4.tar.xz libdbpp-postgresql-40772ae759fe26acc69bebefa0eda173dbd981e4.zip |
Refactor to remove some duplication
Diffstat (limited to 'libpqpp/pq-selectbase.cpp')
-rw-r--r-- | libpqpp/pq-selectbase.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/libpqpp/pq-selectbase.cpp b/libpqpp/pq-selectbase.cpp index 1ede6b8..7dbdb4f 100644 --- a/libpqpp/pq-selectbase.cpp +++ b/libpqpp/pq-selectbase.cpp @@ -1,9 +1,28 @@ #include "pq-selectbase.h" +#include "pq-column.h" -PQ::SelectBase::SelectBase() : +PQ::SelectBase::SelectBase(const std::string & sql) : + DB::Command(sql), + DB::SelectCommand(sql), nTuples(0), tuple(0), execRes(NULL) { } +PQ::SelectBase::~SelectBase() +{ + if (execRes) { + PQclear(execRes); + } +} + +void +PQ::SelectBase::createColumns(PGresult * execRes) +{ + unsigned int nFields = PQnfields(execRes); + for (unsigned int f = 0; f < nFields; f += 1) { + insertColumn(DB::ColumnPtr(new Column(this, f))); + } +} + |