-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDBConnect.h
60 lines (39 loc) · 1.29 KB
/
DBConnect.h
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
#pragma once
#include "DBRecord.h"
#define BEGIN_TRANSCTION L"BEGIN TRANSACTION;"
#define END_TRANSCTION L"COMMIT;"
typedef Sql_Stmt_Ptr HQUERY;
class CDBConnect//: //public IDBConnect
{
public:
CDBConnect();
CDBConnect(WSTR dbPath);
~CDBConnect();
I32 Open(WSTR path);
BOOL IsOpen();
void Close();
I32 ExecSql(const WSTR sql);
I32 ExecStmt(Sql_Stmt_Ptr& stmt);
I32 TransactionBegin();
I32 TransactionCommit();
I32 TansactionRollback();
template<class ...T>
I32 Query(const WSTR sql, CRecordList<T...>& outRecords);
template<class ...T>
I32 QueryStmt(Sql_Stmt_Ptr& stmt, CRecordList<T...>& outRecords);
template<class ...T>
HQUERY XQuery(const WSTR sql, CRecordList<T...>& outRecords, int nCount = 100); //·ÖÅú²éѯ
template<class ...T>
I32 XQuery(HQUERY& hQ, CRecordList<T...>& outRecords, int nCount = 100); //·ÖÅú¼ÌÐø²éѯ
LIST<WSTR> GetTablesNames();
Sql_Stmt_Ptr PrepareSql(const WSTR sql);
template<class T>
int BindStmt(Sql_Stmt_Ptr& stmt,int nSet,T val);
int StmtReset(Sql_Stmt_Ptr& stmt);
BOOL IsEffectStmt(Sql_Stmt_Ptr& stmt);
private:
template<class ...T>
I32 QueryWithCount(HQUERY& hQ, CRecordList<T...>& outRecords, int nCount);
Db_Ptr m_DBHandle;
};
#include "DBConnect_impl.hpp"