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.

46 lines
1.7 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef _SQLITE_base_class_h_
  2. #define _SQLITE_base_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. #include <sqlite3.h>
  8. #ifdef DEBUG_EXTRA
  9. #define DEBUG_SQLITE_QUERIES
  10. #endif
  11. class SQLite_Connector{
  12. private:
  13. basicLogCollection * m_pLog;
  14. bool m_bIsConnected;
  15. basicMutex m_mAccessMutex;
  16. sqlite3 * m_pDBLink;
  17. sqlite3_stmt * m_pResult;
  18. //MYSQL_ROW m_pRow;
  19. char m_pDBName[MAX_PATH];
  20. int m_nFLAGS;
  21. bool m_bPersistentConnection;
  22. bool ReConnect( void );
  23. bool Disconnect( void );
  24. public:
  25. SQLite_Connector();
  26. SQLite_Connector( CSTR DBHost, CSTR DBUser, CSTR DBPassword, U16 Port = 3306 );
  27. SQLite_Connector( CSTR DBName, CSTR DBHost, CSTR DBUser, CSTR DBPassword, U16 Port = 3306 );
  28. //MySQL_Connector( char *LocalUnixSocket, char *DBUser, char* DBPassword );
  29. virtual ~SQLite_Connector();
  30. bool Connect( CSTR FileName, int AUX_FLAGS = SQLITE_OPEN_FULLMUTEX, bool Persistent = false );
  31. CSTR escapeString( CSTR str );
  32. CSTR escapeBinary( uint8_t *Data, uint32_t Size );
  33. bool isConnected( void ){ return m_bIsConnected; };
  34. uint64_t QueryID( CSTR QS );
  35. bool SilentQuery( CSTR QS );
  36. AAssoc * Query( CSTR QS, bool useCache = false );
  37. void deleteResult( AAssoc *&R );
  38. };
  39. void deleteResult( AAssoc *&ptr );
  40. //extern MySQL_Connector DBC;
  41. #endif