1 #ifndef _WX_DATABASE_H_ 2 #define _WX_DATABASE_H_ 20 virtual bool Open(
const wxString& strDatabase) = 0;
29 virtual bool Close() = 0;
32 virtual bool IsOpen() = 0;
36 virtual void BeginTransaction() = 0;
38 virtual void Commit() = 0;
40 virtual void RollBack() = 0;
44 virtual int RunQuery(
const wxString& strQuery);
46 virtual int RunQuery(
const wxString& strQuery,
bool bParseQueries) = 0;
62 int ExecuteUpdate(
const wxString& strQuery) {
return RunQuery(strQuery); }
68 virtual bool TableExists(
const wxString& table) = 0;
70 virtual bool ViewExists(
const wxString& view) = 0;
72 virtual wxArrayString GetTables() = 0;
74 virtual wxArrayString GetViews() = 0;
76 virtual wxArrayString GetColumns(
const wxString& table) = 0;
78 virtual wxArrayString GetPKColumns(
const wxString& table) = 0;
88 virtual int GetSingleResultInt(
const wxString& strSQL,
int nField,
bool bRequireUniqueResult =
true);
89 virtual int GetSingleResultInt(
const wxString& strSQL,
const wxString& strField,
bool bRequireUniqueResult =
true);
94 virtual wxString GetSingleResultString(
const wxString& strSQL,
int nField,
bool bRequireUniqueResult =
true);
95 virtual wxString GetSingleResultString(
const wxString& strSQL,
const wxString& strField,
bool bRequireUniqueResult =
true);
100 virtual long GetSingleResultLong(
const wxString& strSQL,
int nField,
bool bRequireUniqueResult =
true);
101 virtual long GetSingleResultLong(
const wxString& strSQL,
const wxString& strField,
bool bRequireUniqueResult =
true);
106 virtual bool GetSingleResultBool(
const wxString& strSQL,
int nField,
bool bRequireUniqueResult =
true);
107 virtual bool GetSingleResultBool(
const wxString& strSQL,
const wxString& strField,
bool bRequireUniqueResult =
true);
112 virtual wxDateTime GetSingleResultDate(
const wxString& strSQL,
int nField,
bool bRequireUniqueResult =
true);
113 virtual wxDateTime GetSingleResultDate(
const wxString& strSQL,
const wxString& strField,
bool bRequireUniqueResult =
true);
118 virtual void* GetSingleResultBlob(
const wxString& strSQL,
int nField, wxMemoryBuffer& Buffer,
bool bRequireUniqueResult =
true);
119 virtual void* GetSingleResultBlob(
const wxString& strSQL,
const wxString& strField, wxMemoryBuffer& Buffer,
bool bRequireUniqueResult =
true);
124 virtual double GetSingleResultDouble(
const wxString& strSQL,
int nField,
bool bRequireUniqueResult =
true);
125 virtual double GetSingleResultDouble(
const wxString& strSQL,
const wxString& strField,
bool bRequireUniqueResult =
true);
128 virtual wxArrayInt GetResultsArrayInt(
const wxString& strSQL,
int nField);
129 virtual wxArrayInt GetResultsArrayInt(
const wxString& strSQL,
const wxString& Field);
131 virtual wxArrayString GetResultsArrayString(
const wxString& strSQL,
int nField);
132 virtual wxArrayString GetResultsArrayString(
const wxString& strSQL,
const wxString& Field);
134 virtual wxArrayLong GetResultsArrayLong(
const wxString& strSQL,
int nField);
135 virtual wxArrayLong GetResultsArrayLong(
const wxString& strSQL,
const wxString& Field);
137 virtual wxArrayDouble GetResultsArrayDouble(
const wxString& strSQL,
int nField);
138 virtual wxArrayDouble GetResultsArrayDouble(
const wxString& strSQL,
const wxString& Field);
141 void CloseResultSets();
143 void CloseStatements();
161 static wxDatabase* GetDatabase(wxConfigBase& config, wxString* err = NULL,
const wxString& path =
"/");
163 #if wxUSE_DATABASE_SQLITE 164 static wxDatabase* GetSqliteDatabase(wxConfigBase& config, wxString* err = NULL);
166 #if wxUSE_DATABASE_POSTGRESQL 167 static wxDatabase* GetPostgresDatabase(wxConfigBase& config, wxString* err = NULL);
169 #if wxUSE_DATABASE_MYSQL 170 static wxDatabase* GetMysqlDatabase(wxConfigBase& config, wxString* err = NULL);
172 #if wxUSE_DATABASE_ODBC 173 static wxDatabase* GetOdbcDatabase(wxConfigBase& config, wxString* err = NULL);
175 #if wxUSE_DATABASE_TDS 176 static wxDatabase* GetTdsDatabase(wxConfigBase& config, wxString* err = NULL);
186 int GetSingleResultInt(
const wxString& strSQL,
const wxVariant* field,
bool bRequireUniqueResult =
true);
187 wxString GetSingleResultString(
const wxString& strSQL,
const wxVariant* field,
bool bRequireUniqueResult =
true);
188 long GetSingleResultLong(
const wxString& strSQL,
const wxVariant* field,
bool bRequireUniqueResult =
true);
189 bool GetSingleResultBool(
const wxString& strSQL,
const wxVariant* field,
bool bRequireUniqueResult =
true);
190 wxDateTime GetSingleResultDate(
const wxString& strSQL,
const wxVariant* field,
bool bRequireUniqueResult =
true);
191 void* GetSingleResultBlob(
const wxString& strSQL,
const wxVariant* field, wxMemoryBuffer& Buffer,
bool bRequireUniqueResult =
true);
192 double GetSingleResultDouble(
const wxString& strSQL,
const wxVariant* field,
bool bRequireUniqueResult =
true);
193 wxArrayInt GetResultsArrayInt(
const wxString& strSQL,
const wxVariant* field);
194 wxArrayString GetResultsArrayString(
const wxString& strSQL,
const wxVariant* field);
195 wxArrayLong GetResultsArrayLong(
const wxString& strSQL,
const wxVariant* field);
196 #if wxCHECK_VERSION(2, 7, 0) 197 wxArrayDouble GetResultsArrayDouble(
const wxString& strSQL,
const wxVariant* field);
209 #endif//_WX_DATABASE_H_ virtual bool ChangeDatabase(const wxString &database)
const wxString & GetTypeName()
Get a descriptive name for the type of database.
int ExecuteUpdate(const wxString &strQuery)
See RunQuery.
wxDatabaseResultSetHashSet m_ResultSets
wxDatabaseResultSet * ExecuteQuery(const wxString &strQuery)
See RunQueryWithResults.
bool IsViaODBC()
Is the connection via ODBC.
WX_DECLARE_HASH_SET(wxDatabaseResultSet *, wxPointerHash, wxPointerEqual, wxDatabaseResultSetHashSet)
void LogStatementForCleanup(wxPreparedStatement *pStatement)
Add prepared statement object pointer to the list for "garbage collection".
void LogResultSetForCleanup(wxDatabaseResultSet *pResultSet)
Add result set object pointer to the list for "garbage collection".
#define WXDLLIMPEXP_DATABASE
wxDatabaseStatementHashSet m_Statements
const wxString & GetLibraryPath()
Get the library path required by the database.