emsApplication/applications/emsConfigurer/mysqlutils.h

53 lines
1.0 KiB
C
Raw Normal View History

2024-09-21 13:57:16 +08:00
#ifndef MYSQLUTILS_H
#define MYSQLUTILS_H
2024-10-12 14:00:37 +08:00
#pragma execution_character_set("utf-8")
2024-09-21 13:57:16 +08:00
#include <string>
2024-10-11 14:20:12 +08:00
#ifdef _USING_QT_MYSQL_CONNECTOR_
#include <QtSql/QSqlDatabase>_
#endif
#ifdef _USING_MYSQL_CONNECTOR_
#include <cppconn/connection.h>
#endif
#ifdef _USING_MYSQL_51_LIB_
#include <WinSock2.h>
2024-10-12 14:00:37 +08:00
#include <mysql.h> //MySQL C API include file
2024-10-11 14:20:12 +08:00
#endif
2024-09-21 13:57:16 +08:00
2024-10-12 14:00:37 +08:00
#include "globalparameters.h"
2024-09-21 13:57:16 +08:00
class MysqlUtils
{
protected:
MysqlUtils();
public:
~MysqlUtils();
static MysqlUtils* getInstance();
void CloseDatabase();
2024-10-11 14:20:12 +08:00
bool OpenDatabase(const std::string& server = "127.0.0.1", int dbport = 3306, const std::string& dbuser = "root", const std::string& dbpasswd = "Hj57471000", const std::string& database="hjems");
2024-09-21 13:57:16 +08:00
2024-10-12 14:00:37 +08:00
int RetrieveTableData(TableData& tbl_data);
2024-09-21 13:57:16 +08:00
private:
2024-10-11 14:20:12 +08:00
#ifdef _USING_QT_MYSQL_CONNECTOR_
QSqlDatabase m_DbConnection;
#endif
#ifdef _USING_MYSQL_CONNECTOR_
sql::Connection* m_DbConnection;
#endif
#ifdef _USING_MYSQL_51_LIB_
MYSQL* m_DbConnection;
#endif
2024-09-21 13:57:16 +08:00
static MysqlUtils m_instance;
};
#endif // MYSQLUTILS_H