summaryrefslogtreecommitdiff
path: root/p2pvr/lib/dbClient.cpp
blob: cdefc9d188b52f7b8eb689aea79dbecbec0dc5a2 (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
#include <pch.hpp>
#include "dbClient.h"
#include <sqlMergeTask.h>

void
DatabaseClient::SqlMergeColumnsInserter(SqlMergeTask * merge, const std::string & name, bool key)
{
	merge->cols.insert(new SqlMergeTask::TargetColumn(name, key));
	if (key) {
		merge->keys.insert(name);
	}
}

void
DatabaseClient::onAllDatasources(const DataSourceCall & call) const
{
	BOOST_FOREACH(const CommonObjects::DataSources::value_type & ds, CommonObjects::datasources) {
		call(ds.second);
	}
}

DatabaseClient::TxHelper::TxHelper(const DatabaseClient * dbc) :
	so(NULL,
		boost::bind(&DatabaseClient::onAllDatasources, dbc, DataSourceCall(boost::bind(&DataSource::commit, _1))),
		boost::bind(&DatabaseClient::onAllDatasources, dbc, DataSourceCall(boost::bind(&DataSource::rollback, _1))))
{
}

DatabaseClient::NoRowsFoundException::NoRowsFoundException() :
	std::runtime_error("No rows found")
{
}