-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTDBDatabase.h
46 lines (38 loc) · 920 Bytes
/
TDBDatabase.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
#ifndef TDBDATABASE_H
#define TDBDATABASE_H
#include <QtSql/QSqlDatabase>
#include <QMessageBox>
#include <QSqlError>
// included by TDBApplication.h
#include <QDebug>
#include "TDBPasswordDialog.h"
class TDBDatabase
{
protected:
QSqlDatabase db;
static int open_count;
static TDBDatabase* default_db;
TDBDatabase(QString host, QString database, QString login, QString password);
~TDBDatabase();
public:
bool transaction ()
{
return db.transaction();
};
bool commit ()
{
return db.commit();
};
static void open();
static void close(bool force = false);
static inline void setup_db(QString host, QString database, QString login, QString password)
{
default_db = new TDBDatabase(host, database, login, password);
}
static inline void remove_db()
{
delete default_db;
default_db = NULL;
}
};
#endif