From 1485c3a9a48b454de8f2a5542a153b957ef60a52 Mon Sep 17 00:00:00 2001
From: wxx <1321839169@qq.com>
Date: 星期六, 09 十一月 2024 15:58:40 +0800
Subject: [PATCH] Merge branch 'master' of ssh://115.28.86.8:29418/~admin/昆仑_1025

---
 Server/王琨元/code/MysqlConn.h |   42 ++++++++++++++++++++++++------------------
 1 files changed, 24 insertions(+), 18 deletions(-)

diff --git "a/Server/\347\216\213\347\220\250\345\205\203/code/MysqlConn.h" "b/Server/\347\216\213\347\220\250\345\205\203/code/MysqlConn.h"
index 00c9917..fe6d6fc 100644
--- "a/Server/\347\216\213\347\220\250\345\205\203/code/MysqlConn.h"
+++ "b/Server/\347\216\213\347\220\250\345\205\203/code/MysqlConn.h"
@@ -2,48 +2,54 @@
 
 #include <string>
 #include <WinSock2.h>
-//#include <mysql.h>
 #include "MySQL/include/mysql.h"
 #include <string.h>
 #include <chrono>
-
+#include <iostream>
+#include <memory>
+#include <queue>
+#include <mutex>
+#include <condition_variable>
+#include <regex>
 #pragma comment(lib,"./MySQL/lib/libmysql.lib")
 
+using namespace std;
 class MysqlConn
 {
 public:
 	// 初始化连接
 	MysqlConn();
 	// 连接数据库
-	bool connect(std::string ip, std::string userName, std::string passwd, std::string db , int port = 3306);
+	//bool connect();
 	// 释放资源
-	~MysqlConn( );
+	~MysqlConn();
 	// 更新数据库  ( insert  update delete )
-	bool update(std::string sql);
+	bool update(string sql);
 	// 查询数据库
-	bool query(std::string sql);
+	bool query(string sql, vector<vector<string>>& result);
+	bool query(string sql);
 	// 得到结果集
 	bool getResult();
 	// 获取结果集的字段
-	std::string getField(int index);
+	string getField(int index);
 	// 事务操作
 	bool transaction();
 	// 提交事务
-	bool commit( );
+	bool commit();
 	// 事务回滚
 	bool rollback();
 
-	void refreshActiveTime( );   // 刷新活跃时间
+
+	void refreshActiveTime();   // 刷新活跃时间
 	long long getActiveTime();   // 获取当前活跃的时间间隔 
 	// 安全校验接口
-	bool isSqlSafe(const std::string& sql);
-
-private:
-
+	bool isSqlSafe(const string& sql);
+	bool isConnected();
+protected:
 	void freeRes();
-	MYSQL* mysql_ = NULL ;
-	MYSQL_RES* res_ = NULL;
-	MYSQL_ROW row_ = nullptr;
-	std::chrono::steady_clock::time_point  activeTime_;
-};
+	MYSQL* m_mysql;
+	MYSQL_RES* m_res;
+	MYSQL_ROW m_row;
+	chrono::steady_clock::time_point  m_activeTime;
 
+};

--
Gitblit v1.8.0