3 #if wxUSE_DATABASE_MYSQL 8 m_pInterface = pInterface;
10 m_pResultBindings = NULL;
11 m_bManageStatement =
false;
17 m_pInterface = pInterface;
18 m_pStatement = pStatement;
19 m_pResultBindings = NULL;
20 m_bManageStatement = bManageStatement;
26 ThrowDatabaseException();
30 int nParameters = m_pInterface->GetMysqlNumFields()(pResultMetadata);
31 m_pResultBindings =
new MYSQL_BIND[nParameters];
32 memset(m_pResultBindings, 0,
sizeof(MYSQL_BIND)*nParameters);
34 MYSQL_BIND* pCurrentBinding = m_pResultBindings;
35 MYSQL_FIELD* pCurrentField = m_pInterface->GetMysqlFetchField()(pResultMetadata);
36 for (
int i=0; i<nParameters; i++)
45 m_BindingWrappers[i] = pParameter;
46 m_FieldLookupMap[strFieldName] = i;
52 m_pInterface->GetMysqlStmtBindResult()(m_pStatement, m_pResultBindings);
53 m_pInterface->GetMysqlFreeResult()(pResultMetadata);
84 for (
int i=0; i<nParameters; i++)
104 while (start != stop)
106 wxDELETE((*start).second);
130 wxString strValue = wxT(
"");
132 if (pResultBinding != NULL)
134 if ((*(pResultBinding->is_null) ==
false))
146 if (pResultBinding != NULL)
148 if ((*(pResultBinding->is_null) ==
false))
150 int nType = pResultBinding->buffer_type;
163 case MYSQL_TYPE_TINY:
164 nValue = *((
char*)(pResultBinding->buffer));
166 case MYSQL_TYPE_SHORT:
167 nValue = *((
short int*)(pResultBinding->buffer));
169 case MYSQL_TYPE_LONG:
170 nValue = *((
long*)(pResultBinding->buffer));
172 case MYSQL_TYPE_LONGLONG:
173 nValue = *((my_ulonglong*)(pResultBinding->buffer));
188 if (pResultBinding != NULL)
190 if ((*(pResultBinding->is_null) ==
false))
191 bValue = (*((
int*)(pResultBinding->buffer)) != 0);
198 wxDateTime returnDate = wxInvalidDateTime;
200 if (pResultBinding != NULL)
202 if ((*(pResultBinding->is_null) ==
false))
204 MYSQL_TIME* pDate = (MYSQL_TIME*)(pResultBinding->buffer);
205 returnDate.Set(pDate->day, wxDateTime::Month(pDate->month-1), pDate->year, pDate->hour, pDate->minute, pDate->second);
213 void* pReturn = NULL;
215 if (pResultBinding != NULL)
217 if ((*(pResultBinding->is_null) ==
false))
219 unsigned long nBufferLength = 0;
220 if (pResultBinding->length)
221 nBufferLength = (*pResultBinding->length);
223 nBufferLength = pResultBinding->buffer_length;
225 wxMemoryBuffer tempBuffer(nBufferLength);
226 void* pBuffer = tempBuffer.GetWriteBuf(nBufferLength);
227 memcpy(pBuffer, pResultBinding->buffer, nBufferLength);
228 tempBuffer.UngetWriteBuf(nBufferLength);
229 tempBuffer.SetDataLen(nBufferLength);
230 tempBuffer.SetBufSize(nBufferLength);
233 pReturn = Buffer.GetData();
237 wxMemoryBuffer tempBuffer(0);
238 tempBuffer.SetDataLen(0);
239 tempBuffer.SetBufSize(0);
245 wxMemoryBuffer tempBuffer(0);
246 tempBuffer.SetDataLen(0);
247 tempBuffer.SetBufSize(0);
256 double dblValue = 0.0;
258 if (pResultBinding != NULL)
260 if ((*(pResultBinding->is_null) ==
false))
262 int nType = pResultBinding->buffer_type;
265 case MYSQL_TYPE_FLOAT:
266 dblValue = *((
float*)(pResultBinding->buffer));
268 case MYSQL_TYPE_DOUBLE:
269 dblValue = *((
double*)(pResultBinding->buffer));
282 my_bool isNull = *(pResultBinding->is_null);
294 wxString msg(_(
"Field '") + strField + _(
"' not found in the resultset"));
295 #if wxUSE_DATABASE_EXCEPTIONS 305 return ((*SearchIterator).second+1);
315 wxString msg(_(
"Field '") + wxString::Format(_(
"%d"), nField) + _(
"' not found in the resultset"));
316 #if wxUSE_DATABASE_EXCEPTIONS 326 return (*finder).second->GetMysqlBind();
342 while (start != stop)
344 (*start).second->ClearBuffer();
349 #endif//wxUSE_DATABASE_MYSQL
virtual wxResultSetMetaData * GetMetaData()
Retrieve the MetaData associated with this result set.
IntToMysqlParameterMap m_BindingWrappers
MYSQL_BIND * m_pResultBindings
MysqlFreeResultType GetMysqlFreeResult()
MysqlStmtErrnoType GetMysqlStmtErrno()
void LogMetaDataForCleanup(wxResultSetMetaData *pMetaData)
Add meta data object pointer to the list for "garbage collection".
virtual long GetResultLong(int nField)
Retrieve a long from the result set by the 1-based field index.
wxMysqlPreparedStatementResultSet(wxMysqlDynamicInterface *pInterface)
StringToIntMap m_FieldLookupMap
virtual int GetResultInt(int nField)
Retrieve an integer from the result set by the 1-based field index.
MysqlNumFieldsType GetMysqlNumFields()
virtual wxDateTime GetResultDate(int nField)
Retrieve a wxDateTime from the result set by the 1-based field index.
MysqlStmtCloseType GetMysqlStmtClose()
virtual double GetResultDouble(int nField)
Retrieve a double from the result set by the 1-based field index.
#define wxDATABASE_FIELD_NOT_IN_RESULTSET
virtual ~wxMysqlPreparedStatementResultSet()
void ThrowDatabaseException()
virtual bool IsFieldNull(int nField)
Check if a field in the current result set record is NULL.
MysqlStmtFreeResultType GetMysqlStmtFreeResult()
MysqlStmtFetchType GetMysqlStmtFetch()
void CloseMetaData()
Close all meta data objects that have been generated but not yet closed.
void SetErrorMessage(const wxString &strErrorMessage)
void SetEncoding(wxFontEncoding encoding)
wxMysqlDynamicInterface * m_pInterface
static int TranslateErrorCode(int nCode)
virtual bool GetResultBool(int nField)
Retrieve a boolean from the result set by the 1-based field index.
MysqlStmtResultMetadataType GetMysqlStmtResultMetadata()
virtual void * GetResultBlob(int nField, wxMemoryBuffer &Buffer)
Retrieve a BLOB from the result set by the 1-based field index.
void SetErrorCode(int nErrorCode)
virtual bool Next()
Move to the next record in the result set.
virtual wxString ConvertFromUnicodeStream(const char *inputBuffer)
const wxCSConv * GetEncoding()
virtual wxString GetResultString(int nField)
Retrieve a wxString from the result set by the 1-based field index.
MYSQL_BIND * GetResultBinding(int nField)
MYSQL_STMT * m_pStatement
virtual void Close()
Close the result set (call wxDatabase::CloseResultSet() instead on the result set)
virtual int LookupField(const wxString &strField)
MysqlStmtErrorType GetMysqlStmtError()