<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Vance Lucas</title>
	
	<link>http://www.vancelucas.com</link>
	<description>Web Entrepreneur and PHP5 Guru</description>
	<lastBuildDate>Wed, 07 Jul 2010 17:37:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/VanceLucas" /><feedburner:info uri="vancelucas" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>MongoDB Gotchas</title>
		<link>http://feedproxy.google.com/~r/VanceLucas/~3/pzILj-u7_z0/</link>
		<comments>http://www.vancelucas.com/blog/mongodb-gotchas/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 17:37:10 +0000</pubDate>
		<dc:creator>Vance Lucas</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[mongodb]]></category>

		<guid isPermaLink="false">http://www.vancelucas.com/?p=562</guid>
		<description><![CDATA[Most developers are coming from a background with relational database-specific experience, and then trying out some new NoSQL databases like MongoDB. Here are some &#8220;gotchas&#8221; I ran into while using MongoDB with my MySQL hat still on:
Queries are case-sensitive
Fields and queries in MongoDB are case-sensitive:

1
2
3
var test1 = db.test.find&#40;&#123;'tags': 'jquery'&#125;&#41;.count&#40;&#41;;
var test2 = db.test.find&#40;&#123;'tags': 'jQuery'&#125;&#41;.count&#40;&#41;;
test1 == test2; [...]]]></description>
			<content:encoded><![CDATA[<p>Most developers are coming from a background with relational database-specific experience, and then trying out some new NoSQL databases like <a href="http://mongodb.org">MongoDB</a>. Here are some &#8220;gotchas&#8221; I ran into while using MongoDB with my MySQL hat still on:</p>
<h3>Queries are case-sensitive</h3>
<p>Fields and queries in MongoDB are case-sensitive:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> test1 <span style="color: #339933;">=</span> db.<span style="color: #660066;">test</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'tags'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'jquery'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">count</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> test2 <span style="color: #339933;">=</span> db.<span style="color: #660066;">test</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'tags'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'jQuery'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">count</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
test1 <span style="color: #339933;">==</span> test2<span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Output is false - they do not query for the same information</span></pre></td></tr></table></div>

<p>This can cause some headaches if you don&#8217;t normalize user input ahead of time. Imagine you already have several posts tagged with &#8216;NoSQL&#8217; and users enter &#8216;nosql&#8217; in a tag search box. If you don&#8217;t normalize how the data is stored internally (like lowercase all tags), your user will see a much smaller set of posts than they are expecting to see. This is something you don&#8217;t have to worry or even think about with MySQL and most other relational databases.</p>
<p>If you can&#8217;t normalize the stored data, but still want a case-insensitive query, then you must perform a slower <a href="http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-RegularExpressions">regular expression query</a>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">db.<span style="color: #660066;">test</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'tags'</span><span style="color: #339933;">:</span> <span style="color: #339933;">/</span>jquery<span style="color: #339933;">/</span>i<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Note the 'i' flag for case-insensitive</span></pre></td></tr></table></div>

<h3>Data is type-sensitive</h3>
<p>Data stored within MongoDB knows it&#8217;s type. There is a small but significant difference between these two records:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'count'</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">102</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 'count' is stored as an int</span>
<span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'count'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;102&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 'count' is stored as a string</span></pre></td></tr></table></div>

<p>This is obvious to any programmer when presented like this, but what may not be obvious is that this also affects how you can query for these records:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// This returns 1 instead of 2, because it only matches the integer value</span>
db.<span style="color: #660066;">test</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'count'</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">102</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">count</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This is due to how MongoDB stores documents internally with <a href="http://bsonspec.org/">BSON</a> (Binary JSON), using various <a href="http://www.mongodb.org/display/DOCS/Data+Types+and+Conventions">MongoDB data types</a>. This means &#8211; like the point above &#8211; that you must pay attention to how you are saving data <em>into</em> MongoDB, because it will affect how you can query for it later.</p>
<h3>Documents sizes are capped at 4MB each</h3>
<p>This isn&#8217;t a big issue for most people, but it&#8217;s something to be aware of if you plan on storing large chunks of text or nesting a bunch of objects inside a single document. <a href="http://www.businessinsider.com/how-we-use-mongodb-2009-11">Nesting comments inside article documents</a> is a particular approach that may give you pause knowing there is an upper threshold on document size.</p>
<p>Note that this limitation is not an issue for storing <em>files</em> in MongoDB because <a href="http://www.mongodb.org/display/DOCS/GridFS">GridFS</a> transparently divides the contents of files larger than 4MB across multiple documents.</p>
<h3>Only one index is used per query</h3>
<p>Simply adding more indexes doesn&#8217;t always help queries run faster. MongoDB can&#8217;t use multiple indexes together like MySQL and other RDBMS can (see &#8220;<a href="http://dev.mysql.com/doc/refman/5.0/en/index-merge-optimization.html">Index Merge Optimization</a>&#8220;). This means that if a query is selecting or sorting based on multiple fields, a compound index should be created with those fields for the query to run most efficiently.</p>
<h3>MongoDB is for high-memory and 64-bit systems only</h3>
<p>Although MongoDB can be downloaded, compiled, and installed on 32-bit systems, it should never be run in production on them. This is because <a href="http://www.mongodb.org/display/DOCS/Indexing+Advice+and+FAQ#IndexingAdviceandFAQ-MakesureyourindexescanfitinRAM.">MongoDB stores all indexes in memory</a> as well as <a href="http://www.mongodb.org/display/DOCS/Caching">memory-mapped files</a> for all disk I/O for increased speed and throughput. While these two facts aren&#8217;t &#8220;gotchas&#8221; themselves &#8211; they are clearly explained on the website &#8211; it does mean that MongoDB can quickly use a lot of memory, especially as the size of your database grows and becomes significant. Since 32-bit systems have an effective <a href="http://en.wikipedia.org/wiki/3_GB_barrier">3GB memory limit</a> of addressable memory space, they prevent you from being able to add more memory as the size of your database grows. This is also something to think about if you plan to run MongoDB on a small VPS with limited memory, even if it is 64-bit. You may be forced into a memory upgrade sooner than you are prepared for if your database is large or rapidly growing.</p>
<h3>Subtle Differences</h3>
<p>When starting out with MongoDB, it&#8217;s easy to draw a lot of parallels to MySQL and make a lot of assumptions based on those similarities. Collections are kind of like tables, fields are kind of like columns, a document is kind of like a row. You may find yourself going on to make more assumptions about how it&#8217;s storing data, how you can query it, what you can do with it, etc. without even knowing it. So while MongoDB has a lot of similar features and is one of the easiest NoSQL databases to transition to from a relational database, it has some very distinct differences &#8220;under the hood&#8221; that you have to be aware of and plan for ahead of time. The <a href="http://www.mongodb.org/display/DOCS/Manual">MongoDB documentation</a> is well-written, and is pretty good at explaining any potential differences or &#8220;gotchas&#8221;, so make sure to read it thoroughly before making the jump &#8211; and watch that first step.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vancelucas.com/blog/mongodb-gotchas/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://www.vancelucas.com/blog/mongodb-gotchas/</feedburner:origLink></item>
		<item>
		<title>NoSQL First Impressions: Object Databases Missed the Boat</title>
		<link>http://feedproxy.google.com/~r/VanceLucas/~3/Z1vIPBxjmWw/</link>
		<comments>http://www.vancelucas.com/blog/nosql-first-impressions-object-databases-missed-the-boat/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 17:00:57 +0000</pubDate>
		<dc:creator>Vance Lucas</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[rdbms oodb]]></category>

		<guid isPermaLink="false">http://www.vancelucas.com/?p=551</guid>
		<description><![CDATA[I&#8217;ve spent the past few weeks here at work researching and playing with NoSQL databases (and especially MongoDB) for a new feature we&#8217;re developing that doesn&#8217;t easily fit into a relational model. And so far, I really like what I see. The profoundness of the shift away from the relational model and the implications that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve spent the past few weeks here at work researching and playing with <a href="http://en.wikipedia.org/wiki/NoSQL">NoSQL</a> databases (and especially <a href="http://mongodb.org">MongoDB</a>) for a new feature we&#8217;re developing that doesn&#8217;t easily fit into a relational model. And so far, I <em>really</em> like what I see. The profoundness of the shift away from the relational model and the implications that has just blow my mind. <strong>You no longer have to fragment your data to persist it</strong><em>.</em> You just store it. That&#8217;s it. No more hours toiling over the design your table schema and how to break apart the data you put together just to fit it into a relational model. You can now store your data exactly how you use it in your application, with no other special needs or <a href="http://en.wikipedia.org/wiki/Object-relational_impedance_mismatch">impedance mismatches</a>. Going back to an <a href="http://en.wikipedia.org/wiki/RDBMS">RDBMS</a> system now just seems illogical &#8211; it&#8217;s like breaking apart a camera tripod just to fit it in the same standard size case you&#8217;ve been using for years instead of just collapsing it and finding a different case that fits it better. All that effort you go though tearing down your tripod and putting it back together every time you use it is wasted and unnecessary. It&#8217;s a symptom of the larger problem that your case doesn&#8217;t fit your tripod.<span id="more-551"></span></p>
<p>Once you fully get the NoSQL viewpoint and the implications it has on  the future of data storage, you have one of those &#8220;why didn&#8217;t anyone  think of this sooner?&#8221; moments. And yes, I know key/value stores like <a href="http://memcached.org/">memcached</a> existed long before this whole new &#8220;NoSQL&#8221; movement, but it&#8217;s not quite  the same thing.</p>
<h3>Object Databases</h3>
<p>Object databases are an interesting case. They are in the &#8220;NoSQL&#8221; category and solve the same problem other NoSQL databases do &#8211; creating a storage mechanism that fits your data instead of making your data fit a predefined rigid storage mechanism. So why didn&#8217;t they catch on? What gives? It&#8217;s anyone&#8217;s guess why object databases didn&#8217;t catch on and achieve widespread adoption, but one thing is for sure &#8211; <strong>object databases really missed the boat</strong> while other NoSQL database technologies are running rings around them.</p>
<p>The primary problem is that most object databases are designed for a specific language, like Java or .NET. Some have more language support than others, but the problem is still the same &#8211; by integrating in directly with a language&#8217;s object model they depend on specific language implementations, which severely limits adoption. They solve the impedance mismatch problem that RDBMSes present, but <strong>fail to provide language-agnostic data persistence and access</strong>, effectively tying their use to specific technology stacks and platforms.</p>
<h3>The Best of Both Worlds</h3>
<p>NoSQL databases are gaining traction like no other database technology has in over 30 years. The reason is that <strong>good NoSQL databases solve both key data storage problems: impedance mismatches AND language-agnosticism.</strong> By storing the data in an intermediary format like JSON (or BSON) and allowing custom file content types, the focus is on the actual data itself instead of specific technologies or data models. The technology stack becomes irrelevant, and the walls to gaining user adoption crumble.</p>
<p>The bottom line is that NoSQL databases are not just the latest fad. They represent a fundamental paradigm shift in data storage and are an entirely new way of thinking about how to store and access your data in a way that makes sense for your actual usage. NoSQL databases are absolutely something you should be paying attention to and following closely &#8211; they are a strong contender to the RDBMS model and will likely become the de-facto data storage choice for most new web applications within a decade.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vancelucas.com/blog/nosql-first-impressions-object-databases-missed-the-boat/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		<feedburner:origLink>http://www.vancelucas.com/blog/nosql-first-impressions-object-databases-missed-the-boat/</feedburner:origLink></item>
		<item>
		<title>MySQL Series: How to Detect UTF-8 and Multi-byte Characters</title>
		<link>http://feedproxy.google.com/~r/VanceLucas/~3/ZAzRTrwH2eQ/</link>
		<comments>http://www.vancelucas.com/blog/mysql-series-how-to-detect-utf-8-and-multi-byte-characters/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 15:44:39 +0000</pubDate>
		<dc:creator>Vance Lucas</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[utf8]]></category>

		<guid isPermaLink="false">http://www.vancelucas.com/?p=542</guid>
		<description><![CDATA[Multi-byte characters can cause quite a few headaches for the unsuspecting webmaster. Sometimes all you need to do to figure out how to fix the problem is detect which database records have UTF-8 data in them and which ones do not. If you&#8217;ve been scanning records manually, stop now. Here&#8217;s a quick query to cure [...]]]></description>
			<content:encoded><![CDATA[<p>Multi-byte characters can cause quite a few headaches for the unsuspecting webmaster. Sometimes all you need to do to figure out how to fix the problem is detect which database records have UTF-8 data in them and which ones do not. If you&#8217;ve been scanning records manually, stop now. Here&#8217;s a quick query to cure your ales:</p>
<p>Return all the rows with multi-byte characters in table <em>posts</em> on field <em>title</em>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span>
<span style="color: #993333; font-weight: bold;">FROM</span> posts
<span style="color: #993333; font-weight: bold;">WHERE</span> LENGTH<span style="color: #66cc66;">&#40;</span>title<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&lt;&gt;</span> CHAR_LENGTH<span style="color: #66cc66;">&#40;</span>title<span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>This does pretty much what it looks like: returns all the rows in the posts table where the title&#8217;s character length does not match the title&#8217;s length. This works because the LENGTH function returns the <em>number of bytes</em> in the string, while the CHAR_LENGTH function returns the <em>number of characters</em> in the string. If the string contains multi-byte characters (individual characters that are made up of more than one byte) like international UTF-8 characters, the two functions will return different numbers and will not be equal, thus including that row in your results.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vancelucas.com/blog/mysql-series-how-to-detect-utf-8-and-multi-byte-characters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vancelucas.com/blog/mysql-series-how-to-detect-utf-8-and-multi-byte-characters/</feedburner:origLink></item>
		<item>
		<title>Get Only Public Class Properties for the Current Class in PHP</title>
		<link>http://feedproxy.google.com/~r/VanceLucas/~3/UG0ZjFBuoOc/</link>
		<comments>http://www.vancelucas.com/blog/get-only-public-class-properties-for-current-class-in-php/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 23:06:01 +0000</pubDate>
		<dc:creator>Vance Lucas</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[class properties]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[oo]]></category>

		<guid isPermaLink="false">http://www.vancelucas.com/?p=525</guid>
		<description><![CDATA[PHP provides two built-in functions to retrieve properties of a given class &#8211; get_object_vars and get_class_vars. Both these functions behave the same exact way, one taking an object as a variable and the other taking a string class name. The tricky thing about the two functions is that they behave differently depending on the call [...]]]></description>
			<content:encoded><![CDATA[<p>PHP provides two built-in functions to retrieve properties of a given class &#8211; <a href="http://php.net/get_object_vars">get_object_vars</a> and <a href="http://php.net/get_class_vars">get_class_vars</a>. Both these functions behave the same exact way, one taking an object as a variable and the other taking a string class name. The tricky thing about the two functions is that they behave differently depending on the call scope, returning all of the class variables available within the called scope. So if you call either function within the current class you need properties from, all properties are returned &#8211; public, protected, and private &#8211; because the current scope has access to them all. This makes seemingly simple things like returning all the public properties within the current class a bit of a pain if you want to keep the code inside the class itself.<br />
<span id="more-525"></span><br />
The obvious solution is to use the functions from a different call scope, which means either moving the call outside the class to the implementation code (yuck), or creating a new function outside the class for it. A lot of suggestions in the PHP manual say to create a new function below the class definition and call it within the class (kind of a proxy function as a workaround), but that seems tacky. Luckily, PHP also provides another way to get a new call scope: <a href="http://php.net/manual/en/functions.anonymous.php">anonymous functions</a> (and <em>closures</em> as of PHP 5.3).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> BobUser
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'bob'</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$publicFlag</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	protected <span style="color: #000088;">$internalFlag</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getFields<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$getFields</span> <span style="color: #339933;">=</span> <span style="color: #990000;">create_function</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'$obj'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'return get_object_vars($obj);'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$getFields</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Returns only 'name' and 'publicFlag'</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>We can also do this the PHP 5.3 way with a much nicer-looking closure:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> BobUser
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// ...</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getFields<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$getFields</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$obj</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #990000;">get_object_vars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$obj</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$getFields</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.vancelucas.com/blog/get-only-public-class-properties-for-current-class-in-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.vancelucas.com/blog/get-only-public-class-properties-for-current-class-in-php/</feedburner:origLink></item>
		<item>
		<title>Why WordPress Should Not Have Won the Open Source CMS Award</title>
		<link>http://feedproxy.google.com/~r/VanceLucas/~3/k8Z65W_H5As/</link>
		<comments>http://www.vancelucas.com/blog/wordpress-and-the-open-source-cms-award/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 19:10:26 +0000</pubDate>
		<dc:creator>Vance Lucas</dc:creator>
				<category><![CDATA[Opinion]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[awards]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Joomla]]></category>
		<category><![CDATA[MODx]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[open source cms awards]]></category>
		<category><![CDATA[SilverStripe]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.vancelucas.com/?p=498</guid>
		<description><![CDATA[Packt Publishing announced the winners for their annual Open Source CMS Award in November, and since then I have been a bit disturbed that the 2009 winner was WordPress. My first reaction was this:
&#8220;&#8230; So a blogging platform won the content management system award? How sad is that?&#8221;
My knee-jerk &#8220;how sad is that?&#8221; reaction comes [...]]]></description>
			<content:encoded><![CDATA[<p>Packt Publishing announced the winners for their annual <a href="http://www.packtpub.com/award">Open Source CMS Award</a> in November, and since then I have been a bit disturbed that the 2009 <a href="http://wordpress.org/development/2009/11/wordpress-wins-cms-award/">winner was WordPress</a>. My first reaction was this:</p>
<blockquote><p>&#8220;&#8230; So a <em>blogging platform</em> won the <em>content management system</em> award? How sad is that?&#8221;</p></blockquote>
<p>My knee-jerk &#8220;how sad is that?&#8221; reaction comes not because I don&#8217;t think WordPress is worthy, but because of what it implies about the state of other open source CMS projects. The reaction comes from the fact that <em>a </em><strong>blogging platform is kicking your CMS&#8217;s ass in its own category</strong>.</p>
<p><span id="more-498"></span></p>
<p>WordPress bridges both the blogging and CMS categories due to the &#8216;Pages&#8217; feature, and is extremely useful for managing a blog-focused website. Mostly. That is, until you want to do something that a CMS should be good at, like have an event calendar, custom form, photo gallery, etc. &#8211; which is why WordPress is not focused on being a CMS in the first place. Yet <em>it does such a better job at the basic things</em> like creating new pages, tagging, categorizing, comments, and having custom SEO-friendly URLs out of the box that it edged out other software projects like <del><a href="http://drupal.org/">Drupal</a></del> <a href="http://modxcms.com/">MODx</a> and <del><a href="http://www.joomla.org/">Joomla!</a></del> <a href="http://www.silverstripe.com/">SilverStripe</a> whose sole focus is content management. Sad indeed.</p>
<p>The fact that I can go through <a href="http://php.opensourcecms.com/scripts/show.php?catid=1&amp;cat=CMS%20/%20Portals">literally hundreds</a> of open source content management systems and still end up settling on WordPress because I know it&#8217;s the only one that won&#8217;t totally confuse my client is what&#8217;s sad. Usability and ease of use matter. They are the number one feature to the end user. If you&#8217;re involved in a CMS project, you need to do better. A <em>lot</em> better. <strong>Right now</strong>.</p>
<p><strong>UPDATE</strong>: Some commenters have pointed out that the awards website has a specific rule:</p>
<blockquote><p>Previous winners of the Overall category are not eligible for the Overall category in 2009. Previous winners compete amongst one another in a separate Hall of Fame category designed specifically for them.</p></blockquote>
<p>Since both Drupal and Joomla! have won the award previously and thus were automatically excluded, I replaced their names with the CMS projects that were 2nd and 3rd behind WordPress (MODx and SilverStripe) instead. The premise of the post still holds true.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vancelucas.com/blog/wordpress-and-the-open-source-cms-award/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		<feedburner:origLink>http://www.vancelucas.com/blog/wordpress-and-the-open-source-cms-award/</feedburner:origLink></item>
		<item>
		<title>MySQL Series: Return NULL Values First With Descending Order</title>
		<link>http://feedproxy.google.com/~r/VanceLucas/~3/_8LjpI1a4Ag/</link>
		<comments>http://www.vancelucas.com/blog/mysql-series-return-null-values-first-with-descending-order/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 21:28:55 +0000</pubDate>
		<dc:creator>Vance Lucas</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.vancelucas.com/?p=486</guid>
		<description><![CDATA[Sometimes there are unique situations where you need to order query results by a particular field in descending order, but also need NULL values first. The default (and logical) behavior of MySQL in this case is to return NULL values last, because in descending order they have the lowest value (none). But what if you [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes there are unique situations where you need to order query results by a particular field in descending order, but also need NULL values first. The default (and logical) behavior of MySQL in this case is to return NULL values last, because in descending order they have the lowest value (none). But what if you really need to reverse this and force NULL values to the top of the result set?<br />
<span id="more-486"></span><br />
I recently ran into this situation with movie results. The business requirement was that the movies be displayed in descending order by release date, so that the newest ones appeared first. Okay, pretty simple &#8211; until I looked at the results. Turns out, we had data on movies that were currently in production, but did not yet have a release date set. I accounted for this earlier by allowing the release date column to be NULL in the table schema, but forgot about the ramifications of that on my queries. These movies were obviously newer, but were always displayed last on the results page because of their NULL release dates. Sounds like the perfect scenario for a conditional statement.</p>
<p>Using the <a href="http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html">MySQL Control Flow Functions</a>, I quickly crafted an IF() statement in the SELECT portion of the query that looked like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #009900;">IF</span><span style="color: #FF00FF;">&#40;</span>m.date_released <span style="color: #CC0099; font-weight: bold;">IS</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #CC0099; font-weight: bold;">OR</span> m.date_released <span style="color: #CC0099;">=</span> <span style="color: #008000;">'0000-00-00'</span><span style="color: #000033;">,</span> <span style="color: #008080;">1</span><span style="color: #000033;">,</span> <span style="color: #008080;">0</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">AS</span> in_production</pre></td></tr></table></div>

<p>So if the release date has a NULL value or has been inserted as a blank string and formatted to &#8216;0000-00-00&#8242;, it is given a value of 1, and 0 otherwise. We then sort descending by our new &#8216;in_production&#8217; alias in the ORDER BY clause to get the NULL or empty values on top (assigned a 1 value), and then by release date and other criteria second.</p>
<p>The whole query looks something like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span> m.<span style="color: #CC0099;">*</span><span style="color: #000033;">,</span> <span style="color: #009900;">IF</span><span style="color: #FF00FF;">&#40;</span>m.date_released <span style="color: #CC0099; font-weight: bold;">IS</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #CC0099; font-weight: bold;">OR</span> m.date_released <span style="color: #CC0099;">=</span> <span style="color: #008000;">'0000-00-00'</span><span style="color: #000033;">,</span> <span style="color: #008080;">1</span><span style="color: #000033;">,</span> <span style="color: #008080;">0</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">AS</span> in_production
<span style="color: #990099; font-weight: bold;">FROM</span> movies <span style="color: #990099; font-weight: bold;">AS</span> m
<span style="color: #990099; font-weight: bold;">ORDER BY</span> in_production <span style="color: #990099; font-weight: bold;">DESC</span><span style="color: #000033;">,</span> m.date_released <span style="color: #990099; font-weight: bold;">DESC</span></pre></td></tr></table></div>

<p>It&#8217;s an easy way to manipulate the result set in MySQL without slowing down the query or issuing multiple queries.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vancelucas.com/blog/mysql-series-return-null-values-first-with-descending-order/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vancelucas.com/blog/mysql-series-return-null-values-first-with-descending-order/</feedburner:origLink></item>
		<item>
		<title>CodeWorks 2009 Dallas</title>
		<link>http://feedproxy.google.com/~r/VanceLucas/~3/AmsbOcs3rnQ/</link>
		<comments>http://www.vancelucas.com/blog/codeworks-2009-dallas/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 05:03:52 +0000</pubDate>
		<dc:creator>Vance Lucas</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Speaking Engagements]]></category>
		<category><![CDATA[codeworks]]></category>
		<category><![CDATA[cw09]]></category>
		<category><![CDATA[speaking]]></category>

		<guid isPermaLink="false">http://www.vancelucas.com/?p=436</guid>
		<description><![CDATA[
I was fortunate enough to be selected as the regional speaker for the Dallas CodeWorks 2009 stop by the Dallas PHP User Group through a community voting and selection process. My talk was entitled Object Oriented Apologetics, and was essentially about letting people know what good object-oriented code is, when to use it, how to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cw.mtacon.com/schedule/speakers#vance_lucas"><img class="alignright" src="http://www.vancelucas.com/wp-content/uploads/2009/09/CW09_Speaker.png" alt="CodeWorks 2009 Speaker" width="150" height="200" /></a><br />
I was fortunate enough to be selected as the regional speaker for the Dallas <a href="http://cw.mtacon.com/">CodeWorks 2009</a> stop by the <a href="http://dallasphp.org">Dallas PHP User Group</a> through a community voting and selection process. My talk was entitled <strong>Object Oriented Apologetics</strong>, and was essentially about letting people know what good object-oriented code is, when to use it, how to use it, and more specifically <em>why</em> to use it over traditional procedural PHP code.<span id="more-436"></span></p>
<h3>Object Oriented Apologetics</h3>
<blockquote><p>In defense of object-oriented programming &#8211; How and why you should use object oriented programming for your next project.This talk is for PHP programmers who are just learning about object oriented code, who cling to old excuses(&#8220;object oriented code is slower&#8221;), or who are otherwise unconvinced of its usefulness. Concrete real-world examples of commonscenarios and challenges that programmers face will be presented, and how taking an object oriented approach is better than a proceduralone in most cases. Copious code examples in both object oriented and procedural approaches will be provided throughout, and thedifferences and benefits of the object oriented approach will be explained.</p></blockquote>
<div id="__ss_2092025" style="width: 425px; text-align: left;"><object style="margin:0px" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=objectorientedapologetics-090929144850-phpapp02&amp;rel=0&amp;stripped_title=object-oriented-apologetics" /><param name="allowfullscreen" value="true" /><embed style="margin:0px" type="application/x-shockwave-flash" width="425" height="355" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=objectorientedapologetics-090929144850-phpapp02&amp;rel=0&amp;stripped_title=object-oriented-apologetics" allowscriptaccess="always" allowfullscreen="true"></embed></object></div>
<p><a href="http://www.slideshare.net/vlucas/object-oriented-apologetics">Download Object Oriented Apologetics on SlideShare</a></p>
<p>If you were in the talk, <a href="http://joind.in/talk/view/722">please rate it on Joind.in</a></p>
<h3>The CodeWorks Experience</h3>
<p>All in all, the CodeWorks roadshow Dallas stop was much smaller than I expected. There were about 20 people in the talk I gave. I suppose it was both a good a bad thing. On one hand, I had a lot of fun connecting with the other speakers and attendees on a more personal level than I would have had the opportunity to do otherwise. I met a lot of new people in the PHP community that I will probably stay connected with on some level, even if it is just <a href="http://twitter.com">Twitter</a> and IRC. We had a lot of fun the night before the presentation day eating together and hanging out.</p>
<p>On the other hand, I know that as a business, the relatively low attendance levels coupled with the high travel expenses could mean that something like this can&#8217;t happen again, which is a shame. This was one of the best efforts I have seen in a while to really lower the price of the conference for attendees by bringing the speakers directly to their cities or at least ones that are close by. Going to <a href="http://www.zendcon.com">ZendCon</a>, for instance, could easily cost up to $2,500 for the whole trip with airfare, hotel stays, and food, if not more.</p>
<p>The bottom line here is that CodeWorks was a good conference that offered a great value for your money. I had a great time meeting and connecting with new people and finally meeting people in real life that I had been communicating with for years. I learned some new things and finally got the kick in the pants I needed to jump into <a href="http://en.wikipedia.org/wiki/Test-driven_development">Test Driven Development</a>, thanks to <a href="http://blog.casey-sweat.us/">Jason Sweat&#8217;</a>s TDD tutorial and hand-holding.</p>
<p>Now I&#8217;m just looking forward to php|tek in May 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vancelucas.com/blog/codeworks-2009-dallas/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.vancelucas.com/blog/codeworks-2009-dallas/</feedburner:origLink></item>
		<item>
		<title>The One Character Block Comment</title>
		<link>http://feedproxy.google.com/~r/VanceLucas/~3/JQJgYyYE3sk/</link>
		<comments>http://www.vancelucas.com/blog/the-one-character-block-comment/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 14:58:10 +0000</pubDate>
		<dc:creator>Vance Lucas</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[code comments]]></category>
		<category><![CDATA[comments]]></category>

		<guid isPermaLink="false">http://www.vancelucas.com/?p=401</guid>
		<description><![CDATA[When debugging, I often find that I have to comment and un-comment a block of code several times during the process of trying to find out what&#8217;s going on. That used to mean typing and deleting comment block characters repetitively, but not anymore. Here&#8217;s a simple solution to that problem: Comment or un-comment an entire [...]]]></description>
			<content:encoded><![CDATA[<p>When debugging, I often find that I have to comment and un-comment a block of code several times during the process of trying to find out what&#8217;s going on. That used to mean typing and deleting comment block characters repetitively, but not anymore. Here&#8217;s a simple solution to that problem: Comment or un-comment an entire code block of code by typing or deleting a single character.</p>
<p>I was able to arrive at this solution by combining the one-line comment with the comment block in a way that takes advantage of the rules the different types of comments have to follow.<br />
<span id="more-401"></span></p>
<h3>The One-Line Comment</h3>
<p>One-line comment rules dictate that everything after the comment characters must be ignored for the rest of that line. They look like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// My code below</span>
<span style="color: #000088;">$someVar</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;foo&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;bar&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;blah&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;code&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$someVar</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/code&gt;&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>The Block Comment</h3>
<p>Block comment rules dictate that once the beginning characters are started, everything up until the ending characters is ignored. They look like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/* My code below
$someVar = array(&quot;foo&quot;, &quot;bar&quot;, &quot;blah&quot;);
echo &quot;&lt;code&gt;&quot;;
print_r($someVar);
echo &quot;&lt;/code&gt;&quot;;
*/</span></pre></td></tr></table></div>

<h3>Combining The Two: The Best of Both Worlds</h3>
<p>Using both those comment style rules, we can combine the two comment styles in a way that will allow us to comment and un-comment a block of code with by adding or deleting a single character. The trick is to make both the beginning and ending lines both single-line AND block style comments, like so:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//* My code below</span>
<span style="color: #000088;">$someVar</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;foo&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;bar&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;blah&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;code&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$someVar</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/code&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// */</span></pre></td></tr></table></div>

<p>In the above example, you notice that the code will still run &#8211; it&#8217;s not commented out because the first line is following the rules of the single-line comment &#8211; ignoring the block comment declaration on the same line. By removing the first backslash at the beginning of the block, we can comment out the entire code block by enabling the block comment style instead of the single-line style. The last single-comment line is ignored because the block comment rules ignore everything up until the end block comment declaration at the end of the line:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/* My code below
$someVar = array(&quot;foo&quot;, &quot;bar&quot;, &quot;blah&quot;);
echo &quot;&lt;code&gt;&quot;;
print_r($someVar);
echo &quot;&lt;/code&gt;&quot;;
// */</span></pre></td></tr></table></div>

<p>So a single character &#8211; a backslash at the very beginning of the block declaration can now comment or un-comment the entire block by switching the comment rules back and forth between single-line and block style. The code examples provided are in PHP, but this trick will work with any language that supports both single-line and block style comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vancelucas.com/blog/the-one-character-block-comment/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		<feedburner:origLink>http://www.vancelucas.com/blog/the-one-character-block-comment/</feedburner:origLink></item>
		<item>
		<title>OKC PHP User Group Reboot</title>
		<link>http://feedproxy.google.com/~r/VanceLucas/~3/SrBN_owPT8s/</link>
		<comments>http://www.vancelucas.com/blog/okc-php-user-group-reboot/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 14:58:00 +0000</pubDate>
		<dc:creator>Vance Lucas</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Speaking Engagements]]></category>
		<category><![CDATA[okcphp]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[PHP DataMapper]]></category>

		<guid isPermaLink="false">http://www.vancelucas.com/?p=368</guid>
		<description><![CDATA[The local Oklahoma City PHP User Group is re-starting with the okcCoCo as the new venue. The new meetings will be on the second Tuesday of each month, starting with Tuesday, June 09, 2009 at 6:30pm as the first official meeting. Visit the official OKC PHP User Group website to register for meeting reminders and [...]]]></description>
			<content:encoded><![CDATA[<p>The local Oklahoma City PHP User Group is re-starting with the <a href="http://okccoco.com">okcCoCo</a> as the new venue. The new meetings will be on the second Tuesday of each month, starting with <strong>Tuesday, June 09, 2009 at 6:30pm</strong> as the first official meeting. Visit the official <a href="http://phpokc.net">OKC PHP User Group website</a> to register for meeting reminders and to connect with other local PHP developers.</p>
<p>I will be presenting my talk on<strong> Building a Data Mapper with PHP5 and the Standard PHP Library</strong>, followed by a discussion on ORMs and whatever else comes up. The presentation will cover all the thought processes, goals, theories, and actual code that goes into building an ORM (or really any other larger project that requires more advance planning). The project that was the basis of this presentation is <a href="http://phpdatamapper.com">phpDataMapper</a> &#8211; an open-source PHP5 data mapper ORM layer that I started in the fall of 2008. It now powers the model layer of <a title="InvoiceMore - Online Billing and Invoicing" href="http://www.invoicemore.com">InvoiceMore</a>, a live web application I launched in March 2009.</p>
<p>This is a presentation I have given before at Tulsa TechFest.</p>
<p><strong><a href="http://blip.tv/file/2249586/">Watch the video of this presentation online</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.vancelucas.com/blog/okc-php-user-group-reboot/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.vancelucas.com/blog/okc-php-user-group-reboot/</feedburner:origLink></item>
		<item>
		<title>jQuery UI Datepicker with AJAX and LiveQuery</title>
		<link>http://feedproxy.google.com/~r/VanceLucas/~3/N15qP4A6Kk8/</link>
		<comments>http://www.vancelucas.com/blog/jquery-ui-datepicker-with-ajax-and-livequery/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 02:22:32 +0000</pubDate>
		<dc:creator>Vance Lucas</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery UI]]></category>
		<category><![CDATA[LiveQuery]]></category>

		<guid isPermaLink="false">http://www.vancelucas.com/?p=293</guid>
		<description><![CDATA[I&#8217;ve been a little aggravated lately trying to get jQuery UI Datepicker to work correctly on dynamically added fields for creating additional line items to invoices for InvoiceMore. It works great for fields already displayed on the page, but it tends to have major issues with dynamically added fields through AJAX or AHAH. Of course [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been a little aggravated lately trying to get <a href="http://jqueryui.com/demos/datepicker/">jQuery UI Datepicker</a> to work correctly on dynamically added fields for creating additional line items to invoices for <a href="http://www.invoicemore.com">InvoiceMore</a>. It works great for fields already displayed on the page, but it tends to have major issues with dynamically added fields through <a href="http://microformats.org/blog/2005/12/18/ajax-vs-ahah/">AJAX or AHAH</a>. Of course it won&#8217;t work out of the box with elements added dynamically to the DOM, so we can use <a href="http://docs.jquery.com/Events/live">jQuery&#8217;s $.live() event</a> (new in 1.3 &#8211; you previously had to use <a href="http://docs.jquery.com/Plugins/livequery">liveQuery</a>) to make it work. The Datepicker works by binding to the focus() event by default, but as of jQuery 1.3.2, the &#8216;focus&#8217; event cannot be monitored by the &#8216;live&#8217; event function. So we&#8217;re stuck with a little work around:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input.calendarSelectDate'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">live</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">datepicker</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>showOn<span style="color: #339933;">:</span><span style="color: #3366CC;">'focus'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>You would think just a simple &#8220;$(this).datepicker()&#8221; call wrapped inside the live() event would work, but it doesn&#8217;t. Turns out that in order to get it working consistently, you have to add the &#8217;showOn: focus&#8217; config option as well as manually focusing on the element with the focus() event. Charming.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vancelucas.com/blog/jquery-ui-datepicker-with-ajax-and-livequery/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://www.vancelucas.com/blog/jquery-ui-datepicker-with-ajax-and-livequery/</feedburner:origLink></item>
	</channel>
</rss>
