Version: 1.0.0
mysql_preparedstatement_wrapper.cpp
Go to the documentation of this file.
1 #include "wx/database/wxprec.h"
2 
3 #if wxUSE_DATABASE_MYSQL
4 
7 {
8  m_pInterface = pInterface;
9  m_pStatement = pStatement;
10 }
11 
13 {
14  Close();
15 }
16 
18 {
19  if (m_pStatement != NULL)
20  {
22  m_pStatement = NULL;
23  }
24 }
25 
26 // set field
27 void wxMysqlPreparedStatementWrapper::SetParam(int nPosition, int nValue)
28 {
29  m_Parameters.SetParam(nPosition, nValue);
30 }
31 
32 void wxMysqlPreparedStatementWrapper::SetParam(int nPosition, double dblValue)
33 {
34  m_Parameters.SetParam(nPosition, dblValue);
35 }
36 
37 void wxMysqlPreparedStatementWrapper::SetParam(int nPosition, const wxString& strValue)
38 {
39  m_Parameters.SetParam(nPosition, strValue);
40 }
41 
43 {
44  m_Parameters.SetParam(nPosition);
45 }
46 
47 void wxMysqlPreparedStatementWrapper::SetParam(int nPosition, const void* pData, long nDataLength)
48 {
49  m_Parameters.SetParam(nPosition, pData, nDataLength);
50 }
51 
52 void wxMysqlPreparedStatementWrapper::SetParam(int nPosition, const wxDateTime& dateValue)
53 {
54  m_Parameters.SetParam(nPosition, dateValue);
55 }
56 
57 void wxMysqlPreparedStatementWrapper::SetParam(int nPosition, bool bValue)
58 {
59  m_Parameters.SetParam(nPosition, bValue);
60 }
61 
63 {
65 }
66 
68 {
69  MYSQL_BIND* pBoundParameters = m_Parameters.GetMysqlParameterBindings();
70 
71  int nBindReturn = m_pInterface->GetMysqlStmtBindParam()(m_pStatement, pBoundParameters);
72  if (nBindReturn != 0)
73  {
76  wxDELETEA(pBoundParameters);
79  }
80  else
81  {
83  if (nReturn != 0)
84  {
87  wxDELETEA(pBoundParameters);
90  }
91  }
92  wxDELETEA(pBoundParameters);
93 
95 }
96 
98 {
99  wxMysqlPreparedStatementResultSet* pResultSet = NULL;
100  MYSQL_BIND* pBoundParameters = m_Parameters.GetMysqlParameterBindings();
101 
102  if (m_pInterface->GetMysqlStmtBindParam()(m_pStatement, pBoundParameters))
103  {
106  wxDELETEA(pBoundParameters);
108  return NULL;
109  }
110  else
111  {
113  {
116  wxDELETEA(pBoundParameters);
118  return NULL;
119  }
120  else
121  {
123  if (pResultSet)
124  pResultSet->SetEncoding(GetEncoding());
125  }
126  }
127  wxDELETEA(pBoundParameters);;
128 
129  return pResultSet;
130 }
131 
132 #endif//wxUSE_DATABASE_MYSQL
wxMysqlPreparedStatementWrapper(wxMysqlDynamicInterface *pInterface, MYSQL_STMT *pStatement)
wxMysqlPreparedStatementParameterCollection m_Parameters
MysqlStmtErrnoType GetMysqlStmtErrno()
MysqlStmtExecuteType GetMysqlStmtExecute()
wxDatabaseResultSet * RunQueryWithResults()
MysqlStmtCloseType GetMysqlStmtClose()
MysqlStmtParamCountType GetMysqlStmtParamCount()
void SetParam(int nPosition, int nValue)
void SetErrorMessage(const wxString &strErrorMessage)
MysqlStmtBindParamType GetMysqlStmtBindParam()
void SetParam(int nPosition, int nValue)
MysqlStmtAffectedRows GetMysqlStmtAffectedRows()
void SetEncoding(wxFontEncoding encoding)
#define wxDATABASE_QUERY_RESULT_ERROR
Definition: errorcodes.h:21
static int TranslateErrorCode(int nCode)
void SetErrorCode(int nErrorCode)
virtual wxString ConvertFromUnicodeStream(const char *inputBuffer)
const wxCSConv * GetEncoding()
MysqlStmtErrorType GetMysqlStmtError()