summaryrefslogtreecommitdiff
path: root/libpqpp/selectcommand.h
blob: f4774d7cdf0bf2f7a21aade48a0e031c9149f842 (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
32
33
34
35
36
37
38
#ifndef PQ_SELECTCOMMAND_H
#define PQ_SELECTCOMMAND_H

#include "../libdbpp/selectcommand.h"
#include "command.h"
#include <vector>
#include <map>

namespace PQ {
	class Connection;
	class Column;
	class SelectCommand : public DB::SelectCommand, public Command {
		public:
			SelectCommand(const Connection *, const std::string & sql, unsigned int no);
			virtual ~SelectCommand();

			bool fetch();
			void execute();
			const DB::Column& operator[](unsigned int) const;
			const DB::Column& operator[](const Glib::ustring&) const;
			unsigned int columnCount() const;
			unsigned int getOrdinal(const Glib::ustring&) const;
		private:
			void fetchTuples();
			mutable bool executed;
			mutable bool txOpened;
			std::vector<Column *> fields;
			std::map<Glib::ustring, Column *> fieldsName;
			int nTuples, tuple;
			PGresult * execRes;

			friend class Column;
	};
}

#endif