Re: retrieving ENUM description from MySQL
| From: | John W. Holmes | Date: | Thu, 20 Nov 2003 03:16:28 +0000 |
| Subject: | Re: retrieving ENUM description from MySQL | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-170379@lists.php.net to get a copy of this message | ||
Alan Lord wrote:
Imagine a database table, field defined as ENUM with a list of allowed types such as "Mr", "Mrs", "Miss", "Dr", "Prof", etc - you get the idea. I've read the MySQL manual and by using SHOW COLUMNS FROM "table_name" LIKE "enum_column_name"; I can get a result. But the string of ENUMs is not an array. It is returned as a string with all types in one string. Anyone got any ideas about how to retrieve it in a better way - else I'll need to start exploding the string...That's the best you're going to get. Read the string and explode() it into an array. That's the only method and why ENUM/SET columns are a PITA. You should be validating the data prior to it going in the database, anyhow, so why have the additional complexity of the ENUM/SET column? -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com