<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Design Disclosure - Portfolio &#38; Personal Blog of Alistair Stead &#187; symfony</title>
	<atom:link href="http://www.designdisclosure.com/category/symfony/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.designdisclosure.com</link>
	<description>Developing web and iphone applications for fun, profit or distraction</description>
	<lastBuildDate>Mon, 07 Dec 2009 23:28:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>symfony APC cache and Memcache session storage</title>
		<link>http://www.designdisclosure.com/2009/11/symfony-apc-cache-and-memcache-session-storage/</link>
		<comments>http://www.designdisclosure.com/2009/11/symfony-apc-cache-and-memcache-session-storage/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 23:22:43 +0000</pubDate>
		<dc:creator>Alistair Stead</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[scaling]]></category>

		<guid isPermaLink="false">http://www.designdisclosure.com/?p=138</guid>
		<description><![CDATA[In a previous post I described some of the reasons why you would want to store your session data in an alternate location to temporary files on your server. I explained the setup of database session storage using Doctrine and how this would allow you to take advantage of storing session data in a database. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-145" title="symfony-memcache" src="http://www.designdisclosure.com/wp-content/uploads/2009/12/symfony-memcache.jpg" alt="symfony-memcache" width="570" height="300" /></p>
<p>In a previous post I described some of the reasons why you would want to store your session data in an alternate location to temporary files on your server. I explained the<a title="symfony Doctrine database session storage" href="http://www.designdisclosure.com/2009/11/symfony-doctri…ession-storage/"> setup of database session storage using Doctrine</a> and how this would allow you to take advantage of storing session data in a database. However depending upon your application requirements storing your session data in a database may cause excessive load on you database. You could of course use a separate dedicated database server to store your session data. However there is an alternate setup that will allow you to centralise your session storage ready for horizontal scaling of your hosting e.g. adding additional web servers.</p>
<p><span id="more-138"></span></p>
<p>symfony provides a very easy way for you to configure your application to use a number of alternate session storage strategies. In this article I will explain the steps needed to setup your application to use first APC as your session storage and then Memcache. Both of these strategies result in the session data being stored in volatile memory on your server and a cookie is stored on the client to maintain reference to the session data. You can set the lifetime of the cookie to control your session timeout.</p>
<h2>Install APC and Memcached modules</h2>
<p>First we need to ensure that your server has the required packages installed. I am using Ubuntu 9.04 in this example but the packages are available for your preferred linux distro. To install the required packages run the following commands.</p>
<p>Install the required PHP modules and the correct version of apache to successfully install APC, then install the Pecl APC module.</p>
<pre class="textmate-source"><span class="source source_shell">sudo apt-get install php5-dev php-pear apache2-threaded-dev
sudo pecl install apc</span></pre>
<p>Install memcache</p>
<pre class="textmate-source"><span class="source source_shell">sudo apt-get install memcached</span></pre>
<h2>Configure APC session storage</h2>
<p>Once you have your server setup with the required packages you need to configure symfony to use your preferred session storage strategy. To do this you simply need to modify the factories.yml file for you application. You need to modify the section of the factories.yml that defines your application storage strategy e.g.</p>
<p>Amend your factories.yml to include the following settings then change the parameters to reflect you setup such as the domain and session name.</p>
<pre class="textmate-source"><span class="source source_yaml"><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">all<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml">
</span></span>  <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">storage<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml">
</span></span>    <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">class<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">sfCacheSessionStorage
</span></span>    <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">param<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml">
</span></span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">session_name<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">sfproject </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span>[required] name of session to use
</span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">session_cookie_path<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">/ </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span>[required] cookie path
</span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">session_cookie_domain<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">example.com </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span>[required] cookie domain
</span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">session_cookie_lifetime<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">+30 days </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span>[required] liftime of cookie
</span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">session_cookie_secure<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">false </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span>[required] send only if secure connection
</span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">session_cookie_http_only<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">true </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span>[required] accessible only via http protocol
</span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">cache<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">
</span></span>        <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">class<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">sfAPCCache </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span>[required] define the cache strategy
</span>        <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">param<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">~ </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span>[required] this empty key is required or you will get warnings</span></span></pre>
<p>Once you have made this change clear the symfony cache and try your application. You will not see any noticeable difference unless you check the symfony toolbar and look for the additional cookie stored on the client.</p>
<p>This example defines the use of sfAPCCache as the session storage strategy. APC stores the session data in memory on your web server making it quicker to access than reading a file or database record.</p>
<h2>Configure Memcache session storage</h2>
<p>To setup memcache session storage it is almost as simple. Amend your factories.yml to include the following settings then change the parameters to reflect your setup including any specific values for your memcache server if you set it up differently.</p>
<pre class="textmate-source"><span class="source source_yaml"><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">all<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml">
</span></span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">storage<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml">
</span></span>    <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">class<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">sfCacheSessionStorage
</span></span>    <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">param<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml">
</span></span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">session_name<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">sfproject </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span>[required] name of session to use
</span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">session_cookie_path<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">/ </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span>[required] cookie path
</span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">session_cookie_domain<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">example.com </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span>[required] cookie domain
</span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">session_cookie_lifetime<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">+30 days </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span>[required] liftime of cookie
</span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">session_cookie_secure<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">false </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span>[required] send only if secure connection
</span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">session_cookie_http_only<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">true </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span>[required] accessible only via http protocol
</span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">cache<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">
</span></span>        <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">class<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">sfMemcacheCache </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span>[required] define the cache strategy
</span>        <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">param<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml">
</span></span>          <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">servers<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml"> </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> Array of servers
</span>            <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">localserver<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml">
</span></span>              <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">host<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">localhost </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> hostname or IP of mamcache server
</span>              <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">port<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">11211 </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> default memcache port</span></span></pre>
<p>Once you have made this change clear your symfony cache and test your application.</p>
<p>Memcache is a volatile storage strategy very similar to RAM in you PC or Mac. It is very quick to access as the session data is held in the server memory rather than in a file or database. Memcache can also be centralised onto a dedicated memcache server allowing your application to be scaled. The example above uses localhost as the memcache server but the host value of the configured server could be modified to be an alternate dedicated memcache server.</p>
<p>I will be running some performance tests using these strategies and also compare the default file based session storage and also the database session storage strategy. If you have already run these tests I would be keen to see your results.</p>
<p>I hope these examples prove useful. If you have any queries or questions please leave a comment.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=symfony+APC+cache+and+Memcache+session+storage+-+http://tr.im/GfDQ&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.designdisclosure.com/2009/11/symfony-apc-cache-and-memcache-session-storage/&amp;title=symfony+APC+cache+and+Memcache+session+storage" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.designdisclosure.com/2009/11/symfony-apc-cache-and-memcache-session-storage/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://www.designdisclosure.com/2009/11/symfony-apc-cache-and-memcache-session-storage/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.designdisclosure.com/2009/11/symfony-apc-cache-and-memcache-session-storage/&amp;title=symfony+APC+cache+and+Memcache+session+storage" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.designdisclosure.com/2009/11/symfony-apc-cache-and-memcache-session-storage/&amp;title=symfony+APC+cache+and+Memcache+session+storage" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.designdisclosure.com/2009/11/symfony-apc-cache-and-memcache-session-storage/&amp;title=symfony+APC+cache+and+Memcache+session+storage&amp;summary=%0D%0A%0D%0AIn%20a%20previous%20post%20I%20described%20some%20of%20the%20reasons%20why%20you%20would%20want%20to%20store%20your%20session%20data%20in%20an%20alternate%20location%20to%20temporary%20files%20on%20your%20server.%20I%20explained%20the%20setup%20of%20database%20session%20storage%20using%20Doctrine%20and%20how%20this%20would%20allow%20you%20to%20take%20advantage%20of%20storing%20session%20data%20in%20&amp;source=Design Disclosure - Portfolio &amp; Personal Blog of Alistair Stead" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://www.designdisclosure.com/2009/11/symfony-apc-cache-and-memcache-session-storage/&amp;title=symfony+APC+cache+and+Memcache+session+storage" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.designdisclosure.com/2009/11/symfony-apc-cache-and-memcache-session-storage/&amp;t=symfony+APC+cache+and+Memcache+session+storage" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.designdisclosure.com/2009/11/symfony-apc-cache-and-memcache-session-storage/&amp;title=symfony+APC+cache+and+Memcache+session+storage" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.designdisclosure.com/2009/11/symfony-apc-cache-and-memcache-session-storage/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://www.designdisclosure.com/2009/11/symfony-apc-cache-and-memcache-session-storage/&amp;title=symfony+APC+cache+and+Memcache+session+storage&amp;description=%0D%0A%0D%0AIn%20a%20previous%20post%20I%20described%20some%20of%20the%20reasons%20why%20you%20would%20want%20to%20store%20your%20session%20data%20in%20an%20alternate%20location%20to%20temporary%20files%20on%20your%20server.%20I%20explained%20the%20setup%20of%20database%20session%20storage%20using%20Doctrine%20and%20how%20this%20would%20allow%20you%20to%20take%20advantage%20of%20storing%20session%20data%20in%20" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h3  class="related_post_title">Related Articles</h3><ul class="related_post"><li>November 25, 2009 -- <a href="http://www.designdisclosure.com/2009/11/symfony-doctrine-database-session-storage/" title="symfony Doctrine database session storage">symfony Doctrine database session storage</a></li><li>October 8, 2009 -- <a href="http://www.designdisclosure.com/2009/10/propel-doupdate-update-multiple-records-in-a-single-statement/" title="Propel doUpdate update multiple records in a single statement">Propel doUpdate update multiple records in a single statement</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.designdisclosure.com/2009/11/symfony-apc-cache-and-memcache-session-storage/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>symfony Doctrine database session storage</title>
		<link>http://www.designdisclosure.com/2009/11/symfony-doctrine-database-session-storage/</link>
		<comments>http://www.designdisclosure.com/2009/11/symfony-doctrine-database-session-storage/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 22:23:26 +0000</pubDate>
		<dc:creator>Alistair Stead</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[doctrine]]></category>
		<category><![CDATA[sessions]]></category>

		<guid isPermaLink="false">http://www.designdisclosure.com/?p=128</guid>
		<description><![CDATA[Sessions are normally managed by your server and depending upon how involved you get with the PHP setup you need never know how this data is stored. The default setup for PHP is to store session data in temporary files on the server. So why would we want to change how sessions are handled and [...]]]></description>
			<content:encoded><![CDATA[<p>Sessions are normally managed by your server and depending upon how involved you get with the PHP setup you need never know how this data is stored. The default setup for PHP is to store session data in temporary files on the server. So why would we want to change how sessions are handled and what advantage can we gain from any changes we make.</p>
<h2>Why use database session management?</h2>
<p>Sessions allow you maintain persistence within PHP applications. With every HTTP request a PHP application must re-assign every variable and object needed in your application. Sessions allow you to store data that is required to persist past each HTTP request allowing it to be easily retrieved and used.</p>
<p><span id="more-128"></span></p>
<p>Sessions are commonly used when  creating a secure application, used to store the state of a user e.g. if they are logged in or credentials to control access to content.</p>
<p>By storing session data in a database table you are able to create an application interface that will show information about the users that are logged in. This for example could show the number of users logged into the application or show administrators who is logged in.</p>
<p>If you  need to scale your application by adding more than one server, saving your session data in temporary files can lead to major problems. By using database storage you can optimise and unify the session storage, ensuring that session data is always available and consistent.</p>
<p>Obviously there are other solutions for scalable session storage such as APC or MemCache but these solutions are for another post.</p>
<h2>How to setup Doctrine database session storage</h2>
<p>You first need to add a table to you database schema that will be used to store your session data. Although you can create this table manually, adding it to your scheme also created the model classes that you can later use to interact with the table data.</p>
<pre class="textmate-source"><span class="source source_yaml"><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">Session<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml">
</span></span>  <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">columns<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml">
</span></span>    <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">id<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml"> </span></span>{ <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">type<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">string(32)</span></span>, <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">primary<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">true</span></span>, <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">notnull<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">true </span></span>}
    <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">data<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml"> </span></span>{ <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">type<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">string(4000)</span></span>, <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">notnull<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">true </span></span>}
    <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">time<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml"> </span></span>{ <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">type<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">integer(4)</span></span>, <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">notnull<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">true </span></span>}</span></pre>
<p>Once you have added the table to your schema you can build your model and database:</p>
<pre class="textmate-source"><span class="source source_shell">./symfony doctrine:build-all</span></pre>
<p>You then need to configure your symfony application to use this table to store all session data. To do this you need to modify the factories.yml file for your application. Update your file to include the following lines:</p>
<pre class="textmate-source"><span class="source source_yaml"><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">all<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml">
</span></span>  <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">storage<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml">
</span></span>    <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">class<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">sfPDOSessionStorage
</span></span>    <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">param<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml">
</span></span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">db_table<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">session </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> Name of the table storing the sessions
</span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">db_id_col<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">id </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> The primary key column
</span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">db_data_col<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">data </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> The column where the session data will be stored
</span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">db_time_col<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">time </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> The column where the timestamp of the session will be stored
</span>      <span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">database<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">doctrine </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> Name of the database connection to use</span></span></pre>
<p>Once you have modifies your factories.yml file you will need to clear the symfony cache. After that your application should run exactly as it did before except that your users session data will be stored in the database table.</p>
<p>The data column stores all the session data in a serialised form this is deserialized each time a user requests the data. There are many uses for this type of session storage and I hope this brief explanation helps you.</p>
<p>Subscribe to my <a title="Designdisclosure.com RSS Feed" href="feed://www.designdisclosure.com/feed/">RSS feed</a> or follow <a title="Alistair Stead on Twitter" href="http://twitter.com/alistairstead">me on twitter</a> to find out about <a title="setup symfony to use apc or memcache session storage" href="http://www.designdisclosure.com/2009/11/symfony-apc-ca…ession-storage/">setting up symfony to use APC or MemCache session storage.</a></p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=symfony+Doctrine+database+session+storage+-+http://tr.im/FNF3&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.designdisclosure.com/2009/11/symfony-doctrine-database-session-storage/&amp;title=symfony+Doctrine+database+session+storage" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.designdisclosure.com/2009/11/symfony-doctrine-database-session-storage/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://www.designdisclosure.com/2009/11/symfony-doctrine-database-session-storage/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.designdisclosure.com/2009/11/symfony-doctrine-database-session-storage/&amp;title=symfony+Doctrine+database+session+storage" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.designdisclosure.com/2009/11/symfony-doctrine-database-session-storage/&amp;title=symfony+Doctrine+database+session+storage" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.designdisclosure.com/2009/11/symfony-doctrine-database-session-storage/&amp;title=symfony+Doctrine+database+session+storage&amp;summary=Sessions%20are%20normally%20managed%20by%20your%20server%20and%20depending%20upon%20how%20involved%20you%20get%20with%20the%20PHP%20setup%20you%20need%20never%20know%20how%20this%20data%20is%20stored.%20The%20default%20setup%20for%20PHP%20is%20to%20store%20session%20data%20in%20temporary%20files%20on%20the%20server.%20So%20why%20would%20we%20want%20to%20change%20how%20sessions%20are%20handled%20and%20what%20a&amp;source=Design Disclosure - Portfolio &amp; Personal Blog of Alistair Stead" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://www.designdisclosure.com/2009/11/symfony-doctrine-database-session-storage/&amp;title=symfony+Doctrine+database+session+storage" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.designdisclosure.com/2009/11/symfony-doctrine-database-session-storage/&amp;t=symfony+Doctrine+database+session+storage" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.designdisclosure.com/2009/11/symfony-doctrine-database-session-storage/&amp;title=symfony+Doctrine+database+session+storage" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.designdisclosure.com/2009/11/symfony-doctrine-database-session-storage/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://www.designdisclosure.com/2009/11/symfony-doctrine-database-session-storage/&amp;title=symfony+Doctrine+database+session+storage&amp;description=Sessions%20are%20normally%20managed%20by%20your%20server%20and%20depending%20upon%20how%20involved%20you%20get%20with%20the%20PHP%20setup%20you%20need%20never%20know%20how%20this%20data%20is%20stored.%20The%20default%20setup%20for%20PHP%20is%20to%20store%20session%20data%20in%20temporary%20files%20on%20the%20server.%20So%20why%20would%20we%20want%20to%20change%20how%20sessions%20are%20handled%20and%20what%20a" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h3  class="related_post_title">Related Articles</h3><ul class="related_post"><li>November 30, 2009 -- <a href="http://www.designdisclosure.com/2009/11/symfony-apc-cache-and-memcache-session-storage/" title="symfony APC cache and Memcache session storage">symfony APC cache and Memcache session storage</a></li><li>October 8, 2009 -- <a href="http://www.designdisclosure.com/2009/10/propel-doupdate-update-multiple-records-in-a-single-statement/" title="Propel doUpdate update multiple records in a single statement">Propel doUpdate update multiple records in a single statement</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.designdisclosure.com/2009/11/symfony-doctrine-database-session-storage/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Propel doUpdate update multiple records in a single statement</title>
		<link>http://www.designdisclosure.com/2009/10/propel-doupdate-update-multiple-records-in-a-single-statement/</link>
		<comments>http://www.designdisclosure.com/2009/10/propel-doupdate-update-multiple-records-in-a-single-statement/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 19:59:09 +0000</pubDate>
		<dc:creator>Alistair Stead</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[propel]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.designdisclosure.com/?p=103</guid>
		<description><![CDATA[I&#8217;ve been very busy with a number of project launches lately. While working on a little problem today I re-discovered a little gem for use with Propel to update multiple rows in a single statement, rather than iterating through a collection updating and saving each object in turn. This task is simple in SQL but [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been very busy with a number of project launches lately. While working on a little problem today I re-discovered a little gem for use with Propel to update multiple rows in a single statement, rather than iterating through a collection updating and saving each object in turn.</p>
<p>This task is simple in SQL but after a while using any abstraction layer you may find like me you forget about the simple solutions as you spend you day working with complex objects and trying to hydrate custom objects. Blah blah blah&#8230;</p>
<p>The complex solution to a simple problem:</p>
<pre class="textmate-source"><span class="source source_php"><span class="source source_php source_php_embedded source_php_embedded_block source_php_embedded_block_html"><span class="comment comment_line comment_line_double-slash comment_line_double-slash_php"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_php">//</span> Obtain the connection configured
</span><span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>conn</span> <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_php">=</span> <span class="support support_class support_class_php">Propel</span><span class="keyword keyword_operator keyword_operator_class keyword_operator_class_php">::</span><span class="meta meta_function-call meta_function-call_static meta_function-call_static_php">getConnection</span>(<span class="support support_class support_class_php">YourObjectPeer</span><span class="keyword keyword_operator keyword_operator_class keyword_operator_class_php">::</span><span class="constant constant_other constant_other_class constant_other_class_php">DATABASE_NAME</span>)<span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span>
<span class="comment comment_line comment_line_double-slash comment_line_double-slash_php"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_php">//</span> Create a Criteria object that will select the correct rows from the database
</span><span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>selectCriteria</span> <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_php">=</span> <span class="keyword keyword_other keyword_other_new keyword_other_new_php">new</span> <span class="support support_class support_class_php">Criteria</span>()<span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span>
<span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>selectCriteria</span><span class="keyword keyword_operator keyword_operator_class keyword_operator_class_php">-&gt;</span><span class="meta meta_function-call meta_function-call_object meta_function-call_object_php">add</span>(<span class="support support_class support_class_php">YourObjectPeer</span><span class="keyword keyword_operator keyword_operator_class keyword_operator_class_php">::</span><span class="constant constant_other constant_other_class constant_other_class_php">COLUMB_TO_SELECT</span>, <span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">value_to_match</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span>)<span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span>
<span class="comment comment_line comment_line_double-slash comment_line_double-slash_php"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_php">//</span> Create a Criteria object includes the value you want to set
</span><span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>updateCriteria</span> <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_php">=</span> <span class="keyword keyword_other keyword_other_new keyword_other_new_php">new</span> <span class="support support_class support_class_php">Criteria</span>()<span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span>
<span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>updateCriteria</span><span class="keyword keyword_operator keyword_operator_class keyword_operator_class_php">-&gt;</span><span class="meta meta_function-call meta_function-call_object meta_function-call_object_php">add</span>(<span class="support support_class support_class_php">YourObjectPeer</span><span class="keyword keyword_operator keyword_operator_class keyword_operator_class_php">::</span><span class="constant constant_other constant_other_class constant_other_class_php">COLUMB_TO_CHANGE</span>, <span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">value_to_be_set</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span>)<span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span>
<span class="comment comment_line comment_line_double-slash comment_line_double-slash_php"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_php">//</span> Execute the query
</span><span class="support support_class support_class_php">BasePeer</span><span class="keyword keyword_operator keyword_operator_class keyword_operator_class_php">::</span><span class="meta meta_function-call meta_function-call_static meta_function-call_static_php">doUpdate</span>(<span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>selectCriteria</span>, <span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>updateCriteria</span>, <span class="variable variable_other variable_other_php"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_php">$</span>conn</span>)<span class="punctuation punctuation_terminator punctuation_terminator_expression punctuation_terminator_expression_php">;</span></span></span></pre>
<p>Thats it! I hope it helps&#8230;</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Propel+doUpdate+update+multiple+records+in+a+single+statement+-+http://tr.im/BsUt&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.designdisclosure.com/2009/10/propel-doupdate-update-multiple-records-in-a-single-statement/&amp;title=Propel+doUpdate+update+multiple+records+in+a+single+statement" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.designdisclosure.com/2009/10/propel-doupdate-update-multiple-records-in-a-single-statement/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://www.designdisclosure.com/2009/10/propel-doupdate-update-multiple-records-in-a-single-statement/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.designdisclosure.com/2009/10/propel-doupdate-update-multiple-records-in-a-single-statement/&amp;title=Propel+doUpdate+update+multiple+records+in+a+single+statement" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.designdisclosure.com/2009/10/propel-doupdate-update-multiple-records-in-a-single-statement/&amp;title=Propel+doUpdate+update+multiple+records+in+a+single+statement" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.designdisclosure.com/2009/10/propel-doupdate-update-multiple-records-in-a-single-statement/&amp;title=Propel+doUpdate+update+multiple+records+in+a+single+statement&amp;summary=I%27ve%20been%20very%20busy%20with%20a%20number%20of%20project%20launches%20lately.%20While%20working%20on%20a%20little%20problem%20today%20I%20re-discovered%20a%20little%20gem%20for%20use%20with%20Propel%20to%20update%20multiple%20rows%20in%20a%20single%20statement%2C%20rather%20than%20iterating%20through%20a%20collection%20updating%20and%20saving%20each%20object%20in%20turn.%0D%0A%0D%0AThis%20task%20is%20si&amp;source=Design Disclosure - Portfolio &amp; Personal Blog of Alistair Stead" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://www.designdisclosure.com/2009/10/propel-doupdate-update-multiple-records-in-a-single-statement/&amp;title=Propel+doUpdate+update+multiple+records+in+a+single+statement" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.designdisclosure.com/2009/10/propel-doupdate-update-multiple-records-in-a-single-statement/&amp;t=Propel+doUpdate+update+multiple+records+in+a+single+statement" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.designdisclosure.com/2009/10/propel-doupdate-update-multiple-records-in-a-single-statement/&amp;title=Propel+doUpdate+update+multiple+records+in+a+single+statement" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.designdisclosure.com/2009/10/propel-doupdate-update-multiple-records-in-a-single-statement/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://www.designdisclosure.com/2009/10/propel-doupdate-update-multiple-records-in-a-single-statement/&amp;title=Propel+doUpdate+update+multiple+records+in+a+single+statement&amp;description=I%27ve%20been%20very%20busy%20with%20a%20number%20of%20project%20launches%20lately.%20While%20working%20on%20a%20little%20problem%20today%20I%20re-discovered%20a%20little%20gem%20for%20use%20with%20Propel%20to%20update%20multiple%20rows%20in%20a%20single%20statement%2C%20rather%20than%20iterating%20through%20a%20collection%20updating%20and%20saving%20each%20object%20in%20turn.%0D%0A%0D%0AThis%20task%20is%20si" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h3  class="related_post_title">Related Articles</h3><ul class="related_post"><li>November 30, 2009 -- <a href="http://www.designdisclosure.com/2009/11/symfony-apc-cache-and-memcache-session-storage/" title="symfony APC cache and Memcache session storage">symfony APC cache and Memcache session storage</a></li><li>November 25, 2009 -- <a href="http://www.designdisclosure.com/2009/11/symfony-doctrine-database-session-storage/" title="symfony Doctrine database session storage">symfony Doctrine database session storage</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.designdisclosure.com/2009/10/propel-doupdate-update-multiple-records-in-a-single-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>sfPokaYokePlugin symfony Client Side Validation</title>
		<link>http://www.designdisclosure.com/2009/01/sfpokayokeplugin-symfony-client-side-validation/</link>
		<comments>http://www.designdisclosure.com/2009/01/sfpokayokeplugin-symfony-client-side-validation/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 17:05:28 +0000</pubDate>
		<dc:creator>Alistair Stead</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[None]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.blog.co.uk/?p=18</guid>
		<description><![CDATA[The sfPokaYokePlugin (pronounced with the &#8216;e&#8217; on the end e.g. poka-yoki). Simply put it is the use of simple mechanisms that stop mistakes being made. sfPokaYoke provides client-side form validation based on existing action.yml validation files. This validator will provide fully configurable inline errors on blur events and listed errors once the form is submitted. [...]]]></description>
			<content:encoded><![CDATA[<p>The <tt>sfPokaYokePlugin</tt> (pronounced with the &#8216;e&#8217; on the end e.g. poka-yoki).  Simply put it is the use of simple mechanisms that stop mistakes being made.   sfPokaYoke provides client-side form validation based on existing <tt>action.yml</tt> validation files.  This validator will provide fully configurable inline errors on blur events and listed errors once the form is submitted.</p>
<p>This plugin was built after reading &#8220;Designing the Obvious&#8221; by Robert Hoekman, jr. and working with a number of unsatisfactory  validation libraries. It is intended that this plugin will allow you to configure the validation and feedback to make your forms poka yoke devices i.e. impossible for users to make any errors while entering data.</p>
<p>Thanks to Alon Noy for a starting point for the validators! The following symfony validators have been ported to JavaScript implemented in the plugin:</p>
<ul>
<li>sfStringValidator</li>
<li>sfNumberValidator</li>
<li>sfRegexValidator</li>
<li>sfEmailValidator</li>
<li>sfCompareValidator</li>
</ul>
<p>I also plan to implement a client side callback validator that will allow you to call your own client side validators or even call ajax function to run server side validation in real time.<span id="more-18"></span></p>
<h2 id="Installation">Installation</h2>
<p>To install the plugin you can either download the latest files from the symfony wiki or you can checkout the SVN version.</p>
<h3>Install the plugin</h3>
<pre class="textmate-source sunburst"><span class="text text_plain"><span class="meta meta_paragraph meta_paragraph_text">symfony plugin-install <span class="markup markup_underline markup_underline_link markup_underline_link_text">http://plugins.symfony-project.com/sfPokaYokePlugin</span></span></span></pre>
<h3>Add the sfPokaYoke filter to your app filters.yml</h3>
<pre class="textmate-source sunburst"><span class="source source_yaml"><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">rendering<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">~
</span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">web_debug<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">~
</span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">security<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">~
</span></span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> generally, you will want to insert your own filters here
</span>
<span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">poka_yoke<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml">
</span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">class<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">sfPokaYokeFilter
</span></span>
<span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">cache<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span>     <span class="string string_unquoted string_unquoted_yaml">~
</span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">common<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span>    <span class="string string_unquoted string_unquoted_yaml">~
</span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">flash<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span>     <span class="string string_unquoted string_unquoted_yaml">~
</span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">execution<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">~</span></span></span></pre>
<h3>Clear you cache</h3>
<pre class="textmate-source sunburst"><span class="text text_plain"><span class="meta meta_paragraph meta_paragraph_text">symfony cc</span></span></pre>
<p>You&#8217;re done. Any forms that have validation rules will have client-side rules applied too. sfPokaYoke looks for validation rules that match the action name the form will be submitted to. This will also now work with named routes.</p>
<h2>Usage Example</h2>
<p>Once any validation rules are applied to the actions for your form, rules will be created for the client-side validation.</p>
<p>You can configure the client side validation to be triggered on the form submit or when the individual field loses focus. This is done by adding config values to your app.yml and will define how sfPokaYokePlugin responds to the users interaction</p>
<p>If the input value fails any validation rules that error will be inserted next to the input.</p>
<p>You do not need to add any <tt>&lt;div&gt;</tt> tags to capture these in-line errors unless you have a specific location in you form markup where you wish the error to be displayed. sfPokaYoke will look for the symfony form error locations and use those <tt>&lt;div&gt;</tt> tags if available.</p>
<p>If your template includes the following symfony form helper, sfPokaYoke will insert the errors into this location.</p>
<pre class="textmate-source sunburst"><span class="source source_php"><span class="source source_php source_php_embedded source_php_embedded_block source_php_embedded_block_html"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_begin punctuation_section_embedded_begin_php">&lt;?php</span> <span class="support support_function support_function_construct support_function_construct_php">echo</span> <span class="meta meta_function-call meta_function-call_php">form_error</span>(<span class="string string_quoted string_quoted_single string_quoted_single_php"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_php">'</span><span class="meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php">name</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_php">'</span></span>) <span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_end punctuation_section_embedded_end_php"><span class="source source_php">?</span>&gt;</span></span></span></pre>
<p>On form submission a list of all error is inserted as the first child of the form. Each listed error item has an onclick event attached to allow the user to click on the error to focus the form field and resolve the problem.</p>
<pre class="textmate-source sunburst"><span class="text text_html text_html_basic"><span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">ul</span> <span class="meta meta_attribute-with-value meta_attribute-with-value_id meta_attribute-with-value_id_html"><span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_id entity_other_attribute-name_id_html">id</span><span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_html">=</span><span class="string string_quoted string_quoted_double string_quoted_double_html"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_html">"</span><span class="meta meta_toc-list meta_toc-list_id meta_toc-list_id_html">pkykGlobalErrors</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_html">"</span></span></span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span>
   <span class="meta meta_tag meta_tag_inline meta_tag_inline_any meta_tag_inline_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_inline entity_name_tag_inline_any entity_name_tag_inline_any_html">li</span> <span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_html">class</span>=<span class="string string_quoted string_quoted_double string_quoted_double_html"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_html">"</span>globalErrorTitle<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_html">"</span></span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span>The following form information has been completed but it contains errors:<span class="meta meta_tag meta_tag_inline meta_tag_inline_any meta_tag_inline_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_inline entity_name_tag_inline_any entity_name_tag_inline_any_html">li</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span>
   <span class="meta meta_tag meta_tag_inline meta_tag_inline_any meta_tag_inline_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_inline entity_name_tag_inline_any entity_name_tag_inline_any_html">li</span> <span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_html">class</span>=<span class="string string_quoted string_quoted_double string_quoted_double_html"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_html">"</span>errors<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_html">"</span></span> <span class="meta meta_attribute-with-value meta_attribute-with-value_id meta_attribute-with-value_id_html"><span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_id entity_other_attribute-name_id_html">id</span><span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_html">=</span><span class="string string_quoted string_quoted_double string_quoted_double_html"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_html">"</span><span class="meta meta_toc-list meta_toc-list_id meta_toc-list_id_html">pkykGlobal_username</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_html">"</span></span></span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span>Please enter your username.<span class="meta meta_tag meta_tag_inline meta_tag_inline_any meta_tag_inline_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_inline entity_name_tag_inline_any entity_name_tag_inline_any_html">li</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span>
   <span class="meta meta_tag meta_tag_inline meta_tag_inline_any meta_tag_inline_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_inline entity_name_tag_inline_any entity_name_tag_inline_any_html">li</span> <span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_html">class</span>=<span class="string string_quoted string_quoted_double string_quoted_double_html"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_html">"</span>errors<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_html">"</span></span> <span class="meta meta_attribute-with-value meta_attribute-with-value_id meta_attribute-with-value_id_html"><span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_id entity_other_attribute-name_id_html">id</span><span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_html">=</span><span class="string string_quoted string_quoted_double string_quoted_double_html"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_html">"</span><span class="meta meta_toc-list meta_toc-list_id meta_toc-list_id_html">pkykGlobal_password</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_html">"</span></span></span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span>Please enter your password.<span class="meta meta_tag meta_tag_inline meta_tag_inline_any meta_tag_inline_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_inline entity_name_tag_inline_any entity_name_tag_inline_any_html">li</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span>
<span class="meta meta_tag meta_tag_block meta_tag_block_any meta_tag_block_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_block entity_name_tag_block_any entity_name_tag_block_any_html">ul</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span></span></pre>
<p>As each input error is corrected by the user the in-line and list errors are removed.</p>
<h2>Example configuration</h2>
<p>The code block below is an example app.yml file entry to configure the interactions of sfPokaYoke</p>
<pre class="textmate-source sunburst"><span class="source source_yaml"><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">all<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml">
</span></span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> Example app.yml config for sfPokaYoke
</span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">pokayoke<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span><span class="string string_unquoted string_unquoted_yaml">
</span></span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> Turn PokaYoke on and off
</span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">on<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">true
</span></span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> Turn on the debuging this will cause alerts at each validation action
</span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">debug<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">false
</span></span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> Event hooks - validation called on both field blur and form submit
</span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">validate_onblur<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">true
</span></span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">validateon_submit<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">true
</span></span>
<span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> Define which events should display the inline and global form errors
</span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">display_inline_onblur<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">true
</span></span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">display_inline_onsubmit<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">false
</span></span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">display_global_onblur<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">false
</span></span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">display_global_onsubmit<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">false
</span></span>
<span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> Inline error id="error_for(_name)" and class="form_error"
</span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">inline_id_prefix<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">error_for_
</span></span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">inline_class<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">form_error
</span></span>
<span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> &amp;lt;li class="form_error"&amp;gt;&amp;lt;/li&amp;gt; the global error lost class
</span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">global_class<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">form_error
</span></span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> The text used to introduce the global errors list
</span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">global_title<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_quoted string_quoted_single string_quoted_single_yaml"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_yaml">'</span>The following form information has been completed but it contains errors:<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_yaml">'</span></span>
</span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">global_titleclass<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">pkyk_global_title
</span></span>
<span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="comment comment_line comment_line_number-sign comment_line_number-sign_yaml"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_yaml">#</span> Add an onClick event to the items in the global list - click to focus the field with the error
</span><span class="meta meta_leading-tabs meta_leading-tabs_yaml"><span class="meta meta_odd-tab">  </span><span class="meta meta_even-tab">  </span></span><span class="string string_unquoted string_unquoted_yaml"><span class="entity entity_name entity_name_tag entity_name_tag_yaml">global_onclick_focus<span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_yaml">:</span></span> <span class="string string_unquoted string_unquoted_yaml">true;</span></span></span></pre>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=sfPokaYokePlugin+symfony+Client+Side+Validation+-+http://tr.im/Bx3R&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.designdisclosure.com/2009/01/sfpokayokeplugin-symfony-client-side-validation/&amp;title=sfPokaYokePlugin+symfony+Client+Side+Validation" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.designdisclosure.com/2009/01/sfpokayokeplugin-symfony-client-side-validation/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://www.designdisclosure.com/2009/01/sfpokayokeplugin-symfony-client-side-validation/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.designdisclosure.com/2009/01/sfpokayokeplugin-symfony-client-side-validation/&amp;title=sfPokaYokePlugin+symfony+Client+Side+Validation" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.designdisclosure.com/2009/01/sfpokayokeplugin-symfony-client-side-validation/&amp;title=sfPokaYokePlugin+symfony+Client+Side+Validation" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.designdisclosure.com/2009/01/sfpokayokeplugin-symfony-client-side-validation/&amp;title=sfPokaYokePlugin+symfony+Client+Side+Validation&amp;summary=The%20sfPokaYokePlugin%20%28pronounced%20with%20the%20%27e%27%20on%20the%20end%20e.g.%20poka-yoki%29.%20%20Simply%20put%20it%20is%20the%20use%20of%20simple%20mechanisms%20that%20stop%20mistakes%20being%20made.%20%20%20sfPokaYoke%20provides%20client-side%20form%20validation%20based%20on%20existing%20action.yml%20validation%20files.%20%20This%20validator%20will%20provide%20fully%20configurable%20inl&amp;source=Design Disclosure - Portfolio &amp; Personal Blog of Alistair Stead" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://www.designdisclosure.com/2009/01/sfpokayokeplugin-symfony-client-side-validation/&amp;title=sfPokaYokePlugin+symfony+Client+Side+Validation" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.designdisclosure.com/2009/01/sfpokayokeplugin-symfony-client-side-validation/&amp;t=sfPokaYokePlugin+symfony+Client+Side+Validation" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.designdisclosure.com/2009/01/sfpokayokeplugin-symfony-client-side-validation/&amp;title=sfPokaYokePlugin+symfony+Client+Side+Validation" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.designdisclosure.com/2009/01/sfpokayokeplugin-symfony-client-side-validation/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://www.designdisclosure.com/2009/01/sfpokayokeplugin-symfony-client-side-validation/&amp;title=sfPokaYokePlugin+symfony+Client+Side+Validation&amp;description=The%20sfPokaYokePlugin%20%28pronounced%20with%20the%20%27e%27%20on%20the%20end%20e.g.%20poka-yoki%29.%20%20Simply%20put%20it%20is%20the%20use%20of%20simple%20mechanisms%20that%20stop%20mistakes%20being%20made.%20%20%20sfPokaYoke%20provides%20client-side%20form%20validation%20based%20on%20existing%20action.yml%20validation%20files.%20%20This%20validator%20will%20provide%20fully%20configurable%20inl" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h3  class="related_post_title">Related Articles</h3><ul class="related_post"><li>No Related Post</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.designdisclosure.com/2009/01/sfpokayokeplugin-symfony-client-side-validation/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
