News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Giulio Pons' Blog:
PHP to get enum/set values from mysql field
January 21, 2010 @ 11:14:26

Giulio Pons has a quick post with a code snippet showing how to grab the possible values for an ENUM or SET field on a MySQL database.

This function returns an array with the elements allowed in a ENUM or SET mysql field. This can be usefull if you're making some automation and need to retrieve those values without writing them in your code.

The function uses the database's metadata to get the column information for a table and filter out the "enum" information from that. The column information includes the set of values possible and a few simple string handling functions make it easy to grab them. They could also be replaced by a regular expression or two to grab the same information more concisely.

1 comment voice your opinion now!
enum mysql allowed values


blog comments powered by Disqus

Similar Posts

Job Posting: Accucom Seeks Mid-Senior PHP/MySQL Developer (Boston, MA)

Rob Allen: Setting up PHP & MySQL on OS X 10.8 Mountain Lion

DevShed: Paginating Result Sets for a Search Engine Built with MySQL and PHP 5

Peter Goodman's Blog: Observers and Dispatchers

Richard Davey's Blog: WAMP Guide updated for PHP 5.2.3


Community Events





Don't see your event here?
Let us know!


application laravel community symfony configure introduction podcast library threedevsandamaybe code api interview list language release wordpress unittest install developer series

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework