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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#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) :
client(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))))
{
}
void
DatabaseClient::TxHelper::Commit() const
{
client->onAllDatasources(boost::bind(&DataSource::commit, _1));
}
DatabaseClient::NoRowsFoundException::NoRowsFoundException() :
std::runtime_error("No rows found")
{
}
VariableType
operator/(const DatabaseClient::SelectPtr & cmd, unsigned int col)
{
HandleAsVariableType vt;
(*cmd)[col].apply(vt);
return vt.variable;
}
VariableType
operator/(const DatabaseClient::SelectPtr & cmd, const std::string & col)
{
HandleAsVariableType vt;
(*cmd)[col].apply(vt);
return vt.variable;
}
|