summaryrefslogtreecommitdiff
path: root/p2pvr/lib/dbClient.cpp
blob: e085c86e08b901e3ed549cb9a9aa23c6025885c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "dbClient.h"
#include <rdbmsDataSource.h>
#include <sqlVariableBinder.h>

DatabaseClient::SelectPtr
DatabaseClient::Select(const std::string & sql) const
{
	auto db = dataSource<RdbmsDataSource>("postgres");
	return SelectPtr(db->getReadonly().newSelectCommand(sql));
}
DatabaseClient::SelectPtr
DatabaseClient::Select(const std::string & sql, const std::list<VariableType> & vs) const
{
	SelectPtr sel(Select(sql));
	unsigned int offset = 0;
	BOOST_FOREACH(const auto & v, vs) {
		boost::apply_visitor<const SqlVariableBinder, const VariableType>(SqlVariableBinder(sel.get(), offset++), v);
	}
	return sel;
}