How to bake enum fields on mysql?


#1

Good morning,
I’m using Cakephp 2.10.13.
After a search on this forum and on Google, I haven’t found a valid solution about baking tables with “enum” type of fields.
Can you help me?

Fabio


#2

My recollection is that, since enums are not a SQL standard, Cake doesn’t include support for them. Instead, I use int fields with constants defined in the code.


#3

Ok thank you.
I hope that the future releases of cakephp could be compatible with enum field.

Fabio


#4

A lot of people think enums are bad in general, and there’s not a lot of database support for them, so it seems maybe unlikely. Here’s an article detailing some of the problems with them:

http://komlenic.com/244/8-reasons-why-mysqls-enum-data-type-is-evil/

It reminds me of something I forgot earlier, which is that not all of my potential enum use cases are handled with defined constants; some are better off being IDs into other tables that exist solely for this cross-reference purpose.