Re: how to recognize ENUM column in table?

From: Date: Thu, 06 Dec 2007 20:43:27 +0000
Subject: Re: how to recognize ENUM column in table?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-265529@lists.php.net to get a copy of this message
sounds like a solution! :) thanks andrew. -afan Andrew Ballard wrote:
On Dec 6, 2007 1:38 PM, Afan Pasalic <afan@afan.net> wrote:
hi, I use the code from http://www.php.net/manual/en/function.mysql-fetch-field (example #1) I'm getting everything I need but can't recognize if the column is ENUM() type? e.g. column "status" is ENUM('0','1') or ENUM('live','hidden','archive') or something like that. I want to recognize this column and then create a form with radio buttons o 0 o 1 or o live o hidden o archive is it possible? thanks. -afan
The only way I've seen to do this is to first execute the query DESCRIBE my_table and then examine the value of the Type column that is returned for the row that represents the column you are examining in your regular query. You just have to strip the 'ENUM(' and ')' from the beginning and end and then split the remaining string. Andrew


« previous php.general (#265529) next »