I hardly ever use the ENUM datatype, for exactly the reason you have
found.  It's inconvenient to do a query to get the list of values
allowed in the ENUM.  Ralf suggests a solution using SHOW COLUMNS, but
that requires some parsing of the results, which is extra code and
possibly a point of incompatibility.

In my experience, instead of using ENUM, it's better to put values in a
lookup table, and then use a referential integrity constraint to make
sure your main table uses only these values.  Then populating drop-downs
is a lot simpler; just query the lookup table.

ENUM is best used for values that never change:  "male"/"female",
"active"/"inactive", etc.  So if they never change, you might as well
hard-code them instead of looking them up from the db.

If you find yourself regularly using ALTER TABLE to add or remove values
to the ENUM, it's likely that you would be better off using a lookup
table.  Using a lookup table is also more portable to other RDBMS
brands.

Regards,
Bill Karwin 

> -----Original Message-----
> From: Ralph Schindler [mailto:[EMAIL PROTECTED] 
> Sent: Monday, April 30, 2007 9:57 AM
> To: Zend Framework General
> Subject: [fw-general] Zend_Db & Enum to Options
> 
> Has anyone come up with a method for simply retrieving enum 
> options from a table to use in a form's select drop down?  Or 
> would this be considered something that must be implemented 
> as business logic?
> 
> -ralph
> 

Reply via email to