Re: Finding valid ENUM values
- From: Arne Vajhøj <arne@xxxxxxxxxx>
- Date: Sun, 30 Sep 2007 23:13:55 -0400
Roedy Green wrote:
I found this snippet of PHP code. Perhaps you can decipher it and
produce a Java equivalent.
function enum($object) {
list($table, $col) = explode(".", $object);
$row=@mysql_fetch_assoc(mysql_query("SHOW COLUMNS FROM ".$table." LIKE
'".$col."'"));
return ($row ?
explode("','",preg_replace("/(enum|set)\('(.+?)'\)/","\\2",$row['Type']))
: array(0=>'None'));
}
$optarray = enum("table.column");"
A Java snippet:
ResultSet sc = stmt.executeQuery("SHOW COLUMNS FROM et LIKE 'ef'");
while(sc.next()) {
System.out.println(sc.getString("Type"));
Pattern p = Pattern.compile("'(\\w+)'");
Matcher m = p.matcher(sc.getString("Type"));
while (m.find()) {
System.out.println(m.group(1));
}
}
sc.close();
Arne
.
- Follow-Ups:
- Re: Finding valid ENUM values
- From: Rupert Woodman
- Re: Finding valid ENUM values
- References:
- Re: Finding valid ENUM values
- From: Roedy Green
- Re: Finding valid ENUM values
- Prev by Date: Re: (Mis)use of transactions
- Next by Date: Re: Derby eclipse install
- Previous by thread: Re: Finding valid ENUM values
- Next by thread: Re: Finding valid ENUM values
- Index(es):