| | |
| | | |
| | | #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(); |
| | | // éæ¾èµæº |
| | | // �������ݿ� |
| | | bool connect(std::string ip, std::string userName, std::string passwd, std::string db , int port = 3306); |
| | | // �ͷ���Դ |
| | | ~MysqlConn(); |
| | | // æ´æ°æ°æ®åº ( insert update delete ) |
| | | bool update(string sql); |
| | | // æ¥è¯¢æ°æ®åº |
| | | bool query(string sql, vector<vector<string>>& result); |
| | | bool query(string sql); |
| | | // å¾å°ç»æé |
| | | // �������ݿ� ( insert update delete ) |
| | | bool update(std::string sql); |
| | | // ��ѯ���ݿ� |
| | | bool query(std::string sql); |
| | | // �õ������� |
| | | bool getResult(); |
| | | // è·åç»æéçåæ®µ |
| | | string getField(int index); |
| | | // äºå¡æä½ |
| | | // ��ȡ���������ֶ� |
| | | std::string getField(int index); |
| | | // �������� |
| | | bool transaction(); |
| | | // æäº¤äºå¡ |
| | | // �ύ���� |
| | | bool commit(); |
| | | // äºå¡åæ» |
| | | // �����ع� |
| | | bool rollback(); |
| | | |
| | | void refreshActiveTime( ); // ˢ�»�Ծʱ�� |
| | | long long getActiveTime(); // ��ȡ��ǰ��Ծ��ʱ������ |
| | | // ��ȫУ���ӿ� |
| | | bool isSqlSafe(const std::string& sql); |
| | | |
| | | void refreshActiveTime(); // å·æ°æ´»è·æ¶é´ |
| | | long long getActiveTime(); // è·åå½åæ´»è·çæ¶é´é´é |
| | | // å®å
¨æ ¡éªæ¥å£ |
| | | bool isSqlSafe(const string& sql); |
| | | bool isConnected(); |
| | | protected: |
| | | private: |
| | | |
| | | void freeRes(); |
| | | <<<<<<< HEAD |
| | | MYSQL* m_mysql; |
| | | MYSQL_RES* m_res; |
| | | MYSQL_ROW m_row; |
| | | chrono::steady_clock::time_point m_activeTime; |
| | | |
| | | ======= |
| | | MYSQL* mysql_ = NULL ; |
| | | MYSQL_RES* res_ = NULL; |
| | | MYSQL_ROW row_ = nullptr; |
| | | std::chrono::steady_clock::time_point activeTime_; |
| | | >>>>>>> eadb2439512aec3f324b6e75f09b525e8da33edb |
| | | }; |
| | | |