Version: 1.0.0
mysql_database.h
Go to the documentation of this file.
1 #ifndef _WX_DATABASE_MYSQL_DATABASE_H_
2 #define _WX_DATABASE_MYSQL_DATABASE_H_
3 
4 #include "wx/database/wxprec.h"
5 
6 #ifndef DONT_USE_DYNAMIC_DATABASE_LINKING
8 #endif
9 
10 
11 WX_DECLARE_VOIDPTR_HASH_MAP(void*, PointerLookupMap);
12 
14 {
15 public:
16  // Information that can be specified for a MySQL database
17  // host or hostaddr
18  // port
19  // dbname
20  // user
21  // password
22  // ctor
24  wxMysqlDatabase(const wxString& strDatabase);
25  wxMysqlDatabase(const wxString& strServer, const wxString& strDatabase);
26  wxMysqlDatabase(const wxString& strDatabase, const wxString& strUser, const wxString& strPassword);
27  wxMysqlDatabase(const wxString& strServer, const wxString& strDatabase, const wxString& strUser, const wxString& strPassword);
28  wxMysqlDatabase(void* pDatabase) { m_pDatabase = pDatabase; }
29 
30  // dtor
31  virtual ~wxMysqlDatabase();
32 
33  // open database
34  virtual bool Open(const wxString& strDatabase);
35  virtual bool Open(const wxString& strServer, const wxString& strDatabase);
36  virtual bool Open(const wxString& strDatabase, const wxString& strUser, const wxString& strPassword);
37  virtual bool Open(const wxString& strServer, const wxString& strDatabase, const wxString& strUser, const wxString& strPassword);
38 
39  // close database
40  virtual bool Close();
41 
42  //change database
43  virtual bool ChangeDatabase(const wxString& database) ;
44 
45  // Is the connection to the database open?
46  virtual bool IsOpen();
47 
48  // transaction support
49  // transaction support
50  virtual void BeginTransaction();
51  virtual void Commit();
52  virtual void RollBack();
53 
54  // query database
55  virtual int RunQuery(const wxString& strQuery, bool bParseQuery);
56  virtual wxDatabaseResultSet* RunQueryWithResults(const wxString& strQuery);
57 
58  // wxPreparedStatement support
59  virtual wxPreparedStatement* PrepareStatement(const wxString& strQuery);
60 
61  // Database schema API contributed by M. Szeftel (author of wxActiveRecordGenerator)
62  virtual bool TableExists(const wxString& table);
63  virtual bool ViewExists(const wxString& view);
64  virtual wxArrayString GetTables();
65  virtual wxArrayString GetViews();
66  virtual wxArrayString GetColumns(const wxString& table);
67  virtual wxArrayString GetPKColumns(const wxString& table);
68 
69  static int TranslateErrorCode(int nCode);
70  static bool IsAvailable();
71 
72 private:
73  void InitDatabase();
74  void ParseServerAndPort(const wxString& strServer);
75 
76 #ifndef DONT_USE_DYNAMIC_DATABASE_LINKING
78 #endif
79  wxString m_strServer;
80  wxString m_strDatabase;
81  wxString m_strUser;
82  wxString m_strPassword;
83  int m_iPort;
84 
85  void* m_pDatabase;
86 
87 #if wxUSE_UNICODE
88  PointerLookupMap m_ResultSets;
89 #endif
90 };
91 
92 #endif//_WX_DATABASE_MYSQL_DATABASE_H_
93 
virtual bool ChangeDatabase(const wxString &database)
Definition: database.h:26
virtual wxArrayString GetPKColumns(const wxString &table)=0
get Primary keys column names
virtual wxArrayString GetViews()=0
Retrieve all view names.
wxDatabaseResultSetHashSet m_ResultSets
Definition: database.h:200
wxString m_strPassword
virtual wxPreparedStatement * PrepareStatement(const wxString &strQuery)=0
Prepare a SQL statement which can be reused with different parameters.
virtual void RollBack()=0
Rollback the current transaction.
wxString m_strServer
virtual bool IsOpen()=0
Is the connection to the database open?
wxString m_strDatabase
virtual int RunQuery(const wxString &strQuery)
Run an insert, update, or delete query on the database.
Definition: database.cpp:19
virtual void BeginTransaction()=0
Begin a transaction.
wxString m_strUser
wxMysqlDatabase(void *pDatabase)
virtual bool Open(const wxString &strDatabase)=0
virtual bool ViewExists(const wxString &view)=0
Check for the existence of a view by name.
virtual void Commit()=0
Commit the current transaction.
virtual wxArrayString GetColumns(const wxString &table)=0
Retrieve all column names for a table.
virtual bool Close()=0
close database
virtual bool TableExists(const wxString &table)=0
Check for the existence of a table by name.
WX_DECLARE_VOIDPTR_HASH_MAP(void *, PointerLookupMap)
#define WXDLLIMPEXP_DATABASE
wxMysqlDynamicInterface * m_pInterface
virtual wxArrayString GetTables()=0
Retrieve all table names.
virtual wxDatabaseResultSet * RunQueryWithResults(const wxString &strQuery)=0
Run a select query on the database.