<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Sun, 12 Feb 2012 17:52:55 -0600</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Giulio Pons' Blog: PHP to get enum/set values from mysql field]]></title>
      <guid>http://www.phpdeveloper.org/news/13884</guid>
      <link>http://www.phpdeveloper.org/news/13884</link>
      <description><![CDATA[<p>
<i>Giulio Pons</i> has <a href="http://www.barattalo.it/2010/01/19/php-to-get-enum-set-values-from-mysql-field/">a quick post</a> with a code snippet showing how to grab the possible values for an ENUM or SET field on a MySQL database.
</p>
<blockquote>
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.
</blockquote>
<p>
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.
</p>]]></description>
      <pubDate>Thu, 21 Jan 2010 11:14:26 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Debuggable Blog: How to Fetch the ENUM Options of a Field - The CakePHP Enumerable Behavior]]></title>
      <guid>http://www.phpdeveloper.org/news/13183</guid>
      <link>http://www.phpdeveloper.org/news/13183</link>
      <description><![CDATA[<p>
On the Debuggable blog, <i>Tim Koschutzki</i> has <a href="http://www.debuggable.com/posts/How_to_Fetch_the_ENUM_Options_of_a_Field_The_CakePHP_Enumerable_Behavior:4a977c9b-1bdc-44b4-b027-1a54cbdd56cb">added a quick post</a> looking at fetching ENUM options of a database's fields in a CakePHP application.
</p>
<blockquote>
The field users.level is an enum type and can have the values 'guest', 'user', 'admin', 'superadmin' and 'root'. The problem is that it could be possible that new levels were added in the future. [...] So what I came up with is a very simple behavior that can extract the options for any ENUM field. It uses simple caching in order for the query to not be run all the time, so make sure to clear your cache as you update your enum field options in the db.
</blockquote>
<p>
His code snippet creates an EnumerableBehavior for the model and grabs the column names from the given table to check the access level for each and write them out to a cache.
</p>]]></description>
      <pubDate>Tue, 08 Sep 2009 11:47:09 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Benjamin Eberlei's Blog: Enums in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/13144</guid>
      <link>http://www.phpdeveloper.org/news/13144</link>
      <description><![CDATA[<p>
In a <a href="http://www.whitewashing.de/blog/articles/120">new post</a> to his blog <i>Benjamin Eberlei</i> talks about enum data types in PHP and how the <a href="http://us.php.net/splenum">is getting close</a> but still isn't quite there yet.
</p>
<blockquote>
If you want to implement Enum behaviour with a simple string or int value you end up with having to validate the values at several different locations in the code rather than being able to strictly enforce the Enum structure by using typehints.
</blockquote>
<p>
In an effort to try to help the situation he and a colleague came up with an abstract class MyEnum that uses the <a href="http://us.php.net/manual/en/language.oop5.magic.php">__toString</a> method to do value checking. Code examples are included for the class and how to use it.
</p>]]></description>
      <pubDate>Tue, 01 Sep 2009 12:46:34 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Jeremy Johnstone's Blog: Enums in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/11147</guid>
      <link>http://www.phpdeveloper.org/news/11147</link>
      <description><![CDATA[<p>
In <a href="http://www.jeremyjohnstone.com/blog/archives/2008/10/05/enums-in-php/">this new post</a> <i>Jeremy Johnstone</i> looks at creating a class to add that's missing from the basic datatype set of the language - enums.
</p>
<blockquote>
I stumbled across a blog post on <a href="http://it.toolbox.com/blogs/macsploitation/enums-in-php-a-native-implementation-25228">how to implement Enums in PHP via userland code</a> written by Jonathan Hohle. I liked the concept he had, but the implementation was a bit unappealing because it used eval() among other more minor issues. You shouldn't need to generate Enums at runtime, so I took that as a challenge to find a way to do it at compile time, thus making the code much more efficient.
</blockquote>
<p>
His enums would support type hinting and would, ideally, be iterable. He gives the code he's worked up - a base class, another than extends it to make a basic enum structure and some handy changes to support comparisons. A few more changes (and a few other extended classes later) he has some pretty well functioning enums that can even bee iterated through.
</p>]]></description>
      <pubDate>Mon, 06 Oct 2008 07:56:08 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHP in Action Blog: I want enums in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/10159</guid>
      <link>http://www.phpdeveloper.org/news/10159</link>
      <description><![CDATA[<blockquote>I want Enums in PHP</blockquote>
<p>
That's how <a href="http://www.reiersol.com/blog/index.php?op=ViewArticle&articleId=36&blogId=1">this new post</a> on the PHP in Action blog starts this morning. The one thing that he wants is enumeration support in PHP. He shows how it can currently come close with a "roles" system:
</p>
<blockquote>
Useful examples I've encountered in web programming are states or stages in a process and user roles. Another kind of example is one I used in PHP In Action: an authorization system with three fixed roles or categories of user: regular, webmaster and administrator.
</blockquote>
<p>
He sets up an example class that sets constants for the different access levels rather than just relying on strings to handle it (which, as he points out, could very easily be misspelled and not throw any kind of error) .
</p>]]></description>
      <pubDate>Mon, 12 May 2008 08:41:16 -0500</pubDate>
    </item>
  </channel>
</rss>

