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

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