summaryrefslogtreecommitdiff
path: root/p2pvr/lib/dbClient.cpp
blob: b123a0ae60e0c9ae400a500b59c76969953812b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <pch.hpp>
#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;
}