2 messages in com.mysql.lists.plusplusRe: enum type
FromSent OnAttachments
Gianni Pucciani17 Aug 2004 08:51 
Warren Young17 Aug 2004 11:28 
Subject:Re: enum type
From:Warren Young (mysq@etr-usa.com)
Date:08/17/2004 11:28:53 AM
List:com.mysql.lists.plusplus

Gianni Pucciani wrote:

Can anyone tell me how this type in converted in c++ and wich type I have to use if I want to test such a field?

From reading the MySQL docs, it appears that if you don't do anything special, it gets treated as a string type.

However, if you execute a custom query, you can force it to send you the integer value behind the enum:

SELECT enum_column+0 from my_table;

Then you could declare a parallel C enum, and do comparisons against those values. You would treat the column as an integer in this case. When you insert an integer into an enum column, MySQL does the right thing, and C++ can treat enums as integers as well.

I've tried with the followng: ... if (row[o] == "value1") do something... ...

Assuming that row[o] is returning type std::string, operator == isn't going to do what you want. Read the manual on this. What you want is the compare() member function.