Re: how to recognize ENUM column in table?
| From: | Afan Pasalic | Date: | Fri, 07 Dec 2007 16:30:41 +0000 |
| Subject: | Re: how to recognize ENUM column in table? | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-265571@lists.php.net to get a copy of this message | ||
Jim Lucas wrote:
Afan Pasalic wrote:This was my first email. After this one I asked other one where was looking for column type close to ENUM() and the answer was SET() and I was thinking you replied to that one. My bad. I apologize. -afanJim Lucas wrote:I must be missing something else you haven't mentioned, AFAIK this gives you the information that you are asking for. The output shows that it is telling you Type = enum(...) Isn't that what you are asking for? If it were a set type column, then it would say Type = set(...) What are the differences that you speak of / request? Oh.I'm sorry Jim. Yes, you are right.Afan Pasalic wrote:Thanks Jim. But, I was actually looking for column type is like ENUM, with some differences. And it's SET type. -afanhi, 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. -afanTry something like this. my table structure was CREATE TABLEcmsws_com.examples(col1ENUM( '0', '1' ) NOT NULL ,col2ENUM( 'one', 'two', 'three' ) NOT NULL ) ENGINE = MYISAM <?php # setup your db connection and stuff... $result = mysql_query("SHOW COLUMNS FROM examples"); if (!$result) {echo 'Could not run query: ' . mysql_error(); exit;} if (mysql_num_rows($result) > 0) {while ($row = mysql_fetch_assoc($result)) { print_r($row); }} My results were Array ([Field] => col1 [Type] => enum('0','1') [Null] => NO [Key] => [Default] => [Extra] =>) Array ([Field] => col2 [Type] => enum('one','two','three') [Null] => NO [Key] => [Default] => [Extra] =>) Hope this fits the bill