-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDBOperator.h
More file actions
72 lines (60 loc) · 1.43 KB
/
DBOperator.h
File metadata and controls
72 lines (60 loc) · 1.43 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef _DB_OPERATOR_H_
#define _DB_OPERATOR_H_
#include <util/tc_mysql.h>
#include <util/tc_singleton.h>
#include <util/tc_config.h>
#include <string>
#include <map>
//数据源配置
typedef struct _TDBConf
{
string Domain; //域名
string Host; //主机
string port; //端口
string user; //用户名
string password; //密码
string charset; //编码格式
string dbname; //数据库
} DBConf;
class CDBOperator
{
public:
/**
*
*/
CDBOperator();
/**
*
*/
~CDBOperator();
public:
/**
* 初始化
*/
int init(const std::string &dbhost, const std::string &dbuser, const std::string &dbpass,
const std::string &dbname, const std::string &charset, const std::string &dbport);
/**
* [init description]
* @return [description]
*/
int init();
public:
/**
* 数据源配置
*/
void readDBConfig();
/**
* 查询数据库
*/
std::vector<std::map<std::string, std::string>> query(const std::string &strSQL);
private:
//mysql操作对象
tars::TC_Mysql m_mysqlObj;
//数据源配置
DBConf dbConf;
//服务配置
tars::TC_Config *_pFileConf;
};
//singleton
typedef tars::TC_Singleton<CDBOperator, tars::CreateStatic, tars::DefaultLifetime> DBOperatorSingleton;
#endif