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.

44 lines
1.5 KiB

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