Version: 1.0.0
mysql_preparedstatement_parameter_collection.cpp
Go to the documentation of this file.
1 #include "wx/database/wxprec.h"
2 
3 #if wxUSE_DATABASE_MYSQL
4 
6 {
7 }
8 
10 {
11  MysqlParameterArray::iterator start = m_Parameters.begin();
12  MysqlParameterArray::iterator stop = m_Parameters.end();
13 
14  while (start != stop)
15  {
16  if ((*start) != NULL)
17  {
18  wxMysqlParameter* pParameter = (wxMysqlParameter*)(*start);
19  wxDELETE(pParameter);
20  (*start) = NULL;
21  }
22  start++;
23  }
24 }
25 
27 {
28  return m_Parameters.size();
29 }
30 
32 {
33  MYSQL_BIND* pBindings = new MYSQL_BIND[m_Parameters.size()];
34 
35  memset(pBindings, 0, sizeof(MYSQL_BIND)*m_Parameters.size());
36 
37  for (unsigned int i=0; i<m_Parameters.size(); i++)
38  {
39  pBindings[i].buffer_type=m_Parameters[i]->GetBufferType();
40  pBindings[i].buffer=(void*)m_Parameters[i]->GetDataPtr();
41  pBindings[i].buffer_length=m_Parameters[i]->GetDataLength();
42  pBindings[i].length=m_Parameters[i]->GetDataLengthPtr();
43  }
44 
45  return pBindings;
46 }
47 
48 void wxMysqlPreparedStatementParameterCollection::SetParam(int nPosition, int nValue)
49 {
50  //MysqlParameter Parameter(nValue);
51  //SetParam(nPosition, Parameter);
52  wxMysqlParameter* pParameter = new wxMysqlParameter(nValue);
53  pParameter->SetEncoding(GetEncoding());
54  SetParam(nPosition, pParameter);
55 }
56 
57 void wxMysqlPreparedStatementParameterCollection::SetParam(int nPosition, double dblValue)
58 {
59  //MysqlParameter Parameter(dblValue);
60  //SetParam(nPosition, Parameter);
61  wxMysqlParameter* pParameter = new wxMysqlParameter(dblValue);
62  pParameter->SetEncoding(GetEncoding());
63  SetParam(nPosition, pParameter);
64 }
65 
66 void wxMysqlPreparedStatementParameterCollection::SetParam(int nPosition, const wxString& strValue)
67 {
68  //MysqlParameter Parameter(strValue);
69  //SetParam(nPosition, Parameter);
70  wxMysqlParameter* pParameter = new wxMysqlParameter(strValue);
71  pParameter->SetEncoding(GetEncoding());
72  SetParam(nPosition, pParameter);
73 }
74 
76 {
77  //MysqlParameter Parameter;
78  //SetParam(nPosition, Parameter);
79  wxMysqlParameter* pParameter = new wxMysqlParameter();
80  pParameter->SetEncoding(GetEncoding());
81  SetParam(nPosition, pParameter);
82 }
83 
84 void wxMysqlPreparedStatementParameterCollection::SetParam(int nPosition, const void* pData, long nDataLength)
85 {
86  //MysqlParameter Parameter(pData, nDataLength);
87  //SetParam(nPosition, Parameter);
88  wxMysqlParameter* pParameter = new wxMysqlParameter(pData, nDataLength);
89  pParameter->SetEncoding(GetEncoding());
90  SetParam(nPosition, pParameter);
91 }
92 
93 void wxMysqlPreparedStatementParameterCollection::SetParam(int nPosition, const wxDateTime& dateValue)
94 {
95  //MysqlParameter Parameter(dateValue);
96  //SetParam(nPosition, Parameter);
97  wxMysqlParameter* pParameter = new wxMysqlParameter(dateValue);
98  pParameter->SetEncoding(GetEncoding());
99  SetParam(nPosition, pParameter);
100 }
101 
102 void wxMysqlPreparedStatementParameterCollection::SetParam(int nPosition, bool bValue)
103 {
104  //MysqlParameter Parameter(bValue);
105  //SetParam(nPosition, Parameter);
106  wxMysqlParameter* pParameter = new wxMysqlParameter(bValue);
107  pParameter->SetEncoding(GetEncoding());
108  SetParam(nPosition, pParameter);
109 }
110 
112 {
113  // First make sure that there are enough elements in the collection
114  while (m_Parameters.size() < (unsigned int)(nPosition))
115  {
116  //MysqlParameter EmptyParameter;
117  m_Parameters.push_back(NULL);//EmptyParameter);
118  }
119  // Free up any data that is being replaced so the allocated memory isn't lost
120  if (m_Parameters[nPosition-1] != NULL)
121  {
122  delete (m_Parameters[nPosition-1]);
123  }
124  // Now set the new data
125  m_Parameters[nPosition-1] = pParameter;
126 }
127 
128 #endif//wxUSE_DATABASE_MYSQL
void SetParam(int nPosition, int nValue)
void SetEncoding(wxFontEncoding encoding)
const wxCSConv * GetEncoding()