Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Getting Values from a MySql ENUM Field

by greywolf (Priest)
on Aug 16, 2002 at 00:20 UTC ( #190558=note: print w/ replies, xml ) Need Help??


in reply to Getting Values from a MySql ENUM Field

I found this in the MySQL documention:
"If you want to get all possible values for an ENUM column, you should use: SHOW COLUMNS FROM table_name LIKE enum_column_name and parse the ENUM definition in the second column."

I have used something like this in the past:
A query like the one above will give you a string that has all the values in it. You can then split this string on commas into an array. You can then iterate the array and strip out the extra junk.

It's kind of a nasty solution but it will work. I leave the details of how to accomplish this for your 'Fun Time'.

mr greywolf


Comment on Re: Getting Values from a MySql ENUM Field
Re^2: Getting Values from a MySql ENUM Field
by Anonymous Monk on Sep 07, 2010 at 17:31 UTC
    in PHP it would be: preg_match_all( "|'(.+?)'|", $strType, $arrMatches ); Feel free to use the pattern.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://190558]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (17)
As of 2014-07-31 14:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (249 votes), past polls