You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "Defines.h"
|
|
|
|
|
#include "iDataEngine_global.h"
|
|
|
|
|
|
|
|
|
|
#include <QSqlDatabase>
|
|
|
|
|
#include <QSqlQuery>
|
|
|
|
|
#include <QSqlRecord>
|
|
|
|
|
#include <QSqlError>
|
|
|
|
|
|
|
|
|
|
class I_DATAENGINE_EXPORT ZxDbSimple
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// 获取对象,单例模式
|
|
|
|
|
static ZxDbSimple* getInstance();
|
|
|
|
|
|
|
|
|
|
// 关闭
|
|
|
|
|
static void closeDb();
|
|
|
|
|
|
|
|
|
|
// 设置路径,如果_s_ini非空,则从ini文件获取
|
|
|
|
|
static void setURL(QString _s_url,
|
|
|
|
|
QString _s_ini = "",
|
|
|
|
|
bool bForceReopen = false);
|
|
|
|
|
|
|
|
|
|
// 获得数据库连接
|
|
|
|
|
virtual QSqlDatabase getSimpleDb();
|
|
|
|
|
virtual QSqlDatabase* getSimpleDbPtr();
|
|
|
|
|
|
|
|
|
|
// 针对湛江模式,启用一口井一个db文件模式
|
|
|
|
|
bool isDbExtActivated();
|
|
|
|
|
void setDbUrlExt(QString url,
|
|
|
|
|
bool bForceReopen = false);
|
|
|
|
|
virtual QSqlDatabase getSimpleDbExt();
|
|
|
|
|
virtual QSqlDatabase* getSimpleDbExtPtr();
|
|
|
|
|
|
|
|
|
|
// 封装数据库链接操作
|
|
|
|
|
void connTransaction(QString connectionStr = "");
|
|
|
|
|
void connCommit(QString connectionStr = "");
|
|
|
|
|
void connRollback(QString connectionStr = "");
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
ZxDbSimple();
|
|
|
|
|
~ZxDbSimple();
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
static ZxDbSimple* spZxDbSimple;
|
|
|
|
|
static QString sUrl;
|
|
|
|
|
static QString sIni;
|
|
|
|
|
QSqlDatabase m_db;
|
|
|
|
|
|
|
|
|
|
// 针对湛江模式,启用一口井一个db文件模式
|
|
|
|
|
QString sUrlExt;
|
|
|
|
|
QSqlDatabase m_dbExt;
|
|
|
|
|
};
|