summaryrefslogtreecommitdiff
path: root/libpqpp/pq-selectbase.cpp
blob: 54b2a57b65cd4082a5c673a48ad9031e2a50053c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "pq-selectbase.h"
#include "pq-column.h"
#include "pq-binarycolumn.h"
#include "pq-command.h"

PQ::SelectBase::SelectBase(const std::string & sql, const PQ::CommandOptionsCPtr & pqco) :
	DB::Command(sql),
	DB::SelectCommand(sql),
	nTuples(0),
	tuple(0),
	execRes(NULL),
	binary(pqco ? pqco->fetchBinary : false)
{
}

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(binary ? new BinaryColumn(this, f) : new Column(this, f)));
	}
}