Version: 1.0.0
mysql_resultset_metadata.cpp
Go to the documentation of this file.
1 #include "wx/database/wxprec.h"
2 
3 #if wxUSE_DATABASE_MYSQL
4 
5 #include "mysql_com.h"
6 
7 // ctor
9 {
10  m_pInterface = pInterface;
11  m_pMetaData = pMetaData;
12 }
13 
14 // dtor
16 {
18 }
19 
21 {
22  int returnType = COLUMN_UNKNOWN;
23  MYSQL_FIELD* pField = GetColumn(i);
24  if (pField)
25  {
26  switch (pField->type)
27  {
28  case MYSQL_TYPE_SHORT:
29  case MYSQL_TYPE_TINY:
30  case MYSQL_TYPE_LONG:
31  case MYSQL_TYPE_LONGLONG:
32  case MYSQL_TYPE_INT24:
33  returnType = COLUMN_INTEGER;
34  break;
35  case MYSQL_TYPE_FLOAT:
36  case MYSQL_TYPE_DOUBLE:
37  returnType = COLUMN_DOUBLE;
38  break;
39  case MYSQL_TYPE_DATE:
40  case MYSQL_TYPE_DATETIME:
41  case MYSQL_TYPE_NEWDATE:
42  case MYSQL_TYPE_TIMESTAMP:
43  case MYSQL_TYPE_TIME:
44  returnType = COLUMN_DATE;
45  break;
46  case MYSQL_TYPE_TINY_BLOB:
47  case MYSQL_TYPE_MEDIUM_BLOB:
48  case MYSQL_TYPE_LONG_BLOB:
49  case MYSQL_TYPE_BLOB:
50  returnType = COLUMN_BLOB;
51  break;
52  case MYSQL_TYPE_VAR_STRING:
53  case MYSQL_TYPE_STRING:
54  returnType = COLUMN_STRING;
55  break;
56  default:
57  wxPrintf(_("Don't understand type : %d\n"), returnType);
58  returnType = COLUMN_UNKNOWN;
59  break;
60  };
61  }
62  return returnType;
63 }
64 
66 {
67  MYSQL_FIELD* pField = GetColumn(i);
68  if (pField)
69  {
70  return pField->length;
71  }
72  return -1;
73 }
74 
76 {
77  MYSQL_FIELD* pField = GetColumn(i);
78  if (pField)
79  {
80  wxString columnName = ConvertFromUnicodeStream(pField->name);
81  return columnName;
82  }
83  return wxEmptyString;
84 }
85 
87 {
89 }
90 
91 MYSQL_FIELD* wxMysqlResultSetMetaData::GetColumn(int nField)
92 {
93  MYSQL_FIELD* pFields = m_pMetaData->fields;
94  return &(pFields[nField-1]);
95 }
96 
97 #endif//wxUSE_DATABASE_MYSQL
virtual ~wxMysqlResultSetMetaData()
wxMysqlDynamicInterface * m_pInterface
MysqlFreeResultType GetMysqlFreeResult()
MysqlNumFieldsType GetMysqlNumFields()
virtual int GetColumnType(int i)
Retrieve a column's type.
virtual int GetColumnSize(int i)
Retrieve a column's size.
virtual wxString GetColumnName(int i)
Retrieve a column's name.
virtual int GetColumnCount()
Retrieve the number of columns in the result set.
MYSQL_FIELD * GetColumn(int nField)
wxMysqlResultSetMetaData(wxMysqlDynamicInterface *pInterface, MYSQL_RES *pMetaData)
virtual wxString ConvertFromUnicodeStream(const char *inputBuffer)