Rouven: ENUM Inhalt per SQL abfragen?

Beitrag lesen

Hi,

ich gehe mal davon aus, du hast dir gut überlegt ob du wirklich einen ENUM brauchst oder ob nicht eine Tabelle mit Fremdschlüssel sinnvoller ist...
Wenn ja, hier ein Kommentar aus dem entsprechenden Bereich des MySQL-Handbuchs:
--------
If you want to get an array in php with all possible values for an ENUM or SET column, you should use: SHOW COLUMNS FROM table_name LIKE 'enum_column_name' (with or without %-wildcards), and parse it with the following php script:

$result=mysql_query($query);
if(mysql_num_rows($result)>0){
$row=mysql_fetch_row($result);
$options=explode("','",preg_replace("/(enum|set)('(.+?)')/","\2",$row[1]));
}
---------
Weitere Möglichkeiten für einzelne Werte o.ä. kannst du auch mal dort in den Nutzerkommentaren nachschlagen.

MfG
Rouven

--
-------------------
ss:) zu:) ls:& fo:) de:< va:{ ch:? sh:) n4:( rl:? br:$ js:| ie:) fl:(