You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.4 KiB

7 years ago
​
​
​
​
​
7 years ago
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
7 years ago
​
  1. #ifndef _database_class_h_
  2. #define _database_class_h_
  3. #include "../../components/base/basicLogCollection.h"
  4. #include "../../components/base/basicMutex.h"
  5. #include "../../components/base/basicTypes.h"
  6. #include <mysql/mysql.h>
  7. #ifdef DEBUG_EXTRA
  8. #define DEBUG_MYSQL_QUERIES
  9. #endif
  10. class MySQL_Connector
  11. {
  12. private:
  13. basicLogCollection * m_pLog;
  14. bool m_bIsConnected;
  15. basicMutex m_mAccessMutex;
  16. MYSQL * m_pDBLink;
  17. MYSQL_RES * m_pResult;
  18. MYSQL_ROW m_pRow;
  19. CSTR m_pDBName;
  20. CSTR m_pDBHost;
  21. CSTR m_pDBUser;
  22. CSTR m_pDBPassword;
  23. uint16_t m_nPort;
  24. public:
  25. MySQL_Connector();
  26. MySQL_Connector(CSTR DBHost, CSTR DBUser, CSTR DBPassword, U16 Port = 3306);
  27. MySQL_Connector(CSTR DBName, CSTR DBHost, CSTR DBUser, CSTR DBPassword, U16 Port = 3306);
  28. // MySQL_Connector( char *LocalUnixSocket, char *DBUser, char* DBPassword );
  29. virtual ~MySQL_Connector();
  30. bool Connect(CSTR DBHost, CSTR DBUser, CSTR DBPassword, uint16_t Port = 3306);
  31. bool Connect(CSTR DBName, CSTR DBHost, CSTR DBUser, CSTR DBPassword, uint16_t Port = 3306);
  32. bool ReConnect(void);
  33. CSTR escapeString(CSTR str);
  34. CSTR escapeBinary(uint8_t * Data, uint32_t Size);
  35. bool isConnected(void)
  36. {
  37. return m_bIsConnected;
  38. }
  39. uint64_t QueryID(CSTR QS);
  40. void SilentQuery(CSTR QS);
  41. AAssoc * Query(CSTR QS, bool useCache = false);
  42. };
  43. void deleteResult(AAssoc *& ptr);
  44. // extern MySQL_Connector DBC;
  45. #endif