<?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"
	>

<channel>
	<title>LampJunkie.com - Everything related to Linux, PHP, MySQL, Apache, AJAX, Symfony and more</title>
	<atom:link href="http://www.lampjunkie.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lampjunkie.com</link>
	<description>Addicted to Linux  &#38; PHP</description>
	<pubDate>Thu, 17 Jul 2008 00:39:22 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>Custom Tasks in Symfony 1.1</title>
		<link>http://www.lampjunkie.com/2008/07/custom-tasks-in-symfony-11/</link>
		<comments>http://www.lampjunkie.com/2008/07/custom-tasks-in-symfony-11/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 19:04:44 +0000</pubDate>
		<dc:creator>marc</dc:creator>
		
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.lampjunkie.com/?p=39</guid>
		<description><![CDATA[Awhile ago I wrote a post on how to create custom tasks in symfony 1.0. A reader posted a question on how to do this in symfony 1.1. At first I figured out a solution of how to do it manually, but then I discovered this tutorial on the symfony cookbook section: http://www.symfony-project.org/cookbook/1_1/en/tasks which describes [...]]]></description>
			<content:encoded><![CDATA[<p>Awhile ago I wrote a <a href="http://www.lampjunkie.com/2008/04/custom-tasks-in-symfony-10">post on how to create custom tasks in symfony 1.0</a>. A reader posted a question on how to do this in symfony 1.1. At first I figured out a solution of how to do it manually, but then I discovered this tutorial on the symfony cookbook section: <a href="http://www.symfony-project.org/cookbook/1_1/en/tasks">http://www.symfony-project.org/cookbook/1_1/en/tasks</a> which describes exactly how to do it!</p>
<p>As the tutorial describes, there is a new symfony task to help creating the skeleton classes for your own tasks! Sweet, it couldn&#8217;t be any simpler!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lampjunkie.com/2008/07/custom-tasks-in-symfony-11/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PuTTY with Tabs (PuTTY Connection Manager)</title>
		<link>http://www.lampjunkie.com/2008/05/putty-with-tabs-putty-connection-manager/</link>
		<comments>http://www.lampjunkie.com/2008/05/putty-with-tabs-putty-connection-manager/#comments</comments>
		<pubDate>Fri, 23 May 2008 22:52:44 +0000</pubDate>
		<dc:creator>marc</dc:creator>
		
		<category><![CDATA[Misc]]></category>

		<category><![CDATA[putty]]></category>

		<guid isPermaLink="false">http://www.lampjunkie.com/?p=38</guid>
		<description><![CDATA[Whenever I am using a Windows desktop and I need to connect to various servers via SSH, I use PuTTY. It&#8217;s lightweight and gets the job done without any problems. However, the one problem has always been that I may have 10 different instances open and it&#8217;s a pain in the ass to switch between [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever I am using a Windows desktop and I need to connect to various servers via SSH, I use PuTTY. It&#8217;s lightweight and gets the job done without any problems. However, the one problem has always been that I may have 10 different instances open and it&#8217;s a pain in the ass to switch between them. </p>
<p>In the past I&#8217;ve tried to find other SSH clients for Windows that featured tabbing, but none of them were really quite what I was looking for. I tried <a href="http://en.poderosa.org/">Ponderosa</a>, which was pretty good, but ran into weird issues with the rendering when scrolling in Nano.</p>
<p>Now, today I received a message on a PHP mailing list about the <a href="http://puttycm.free.fr">PuTTY Connection Manager</a> which will manage multiple instances of PuTTY by giving you tabs! Yay!!!!</p>
<p>I encourage anyone who needs to use windows to connect to various servers to check it out:</p>
<p><a href="http://puttycm.free.fr">PuTTY Connection Manager</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lampjunkie.com/2008/05/putty-with-tabs-putty-connection-manager/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Store Symfony Sessions in Database with Propel</title>
		<link>http://www.lampjunkie.com/2008/05/store-symfony-sessions-in-database-with-propel/</link>
		<comments>http://www.lampjunkie.com/2008/05/store-symfony-sessions-in-database-with-propel/#comments</comments>
		<pubDate>Fri, 23 May 2008 17:17:21 +0000</pubDate>
		<dc:creator>marc</dc:creator>
		
		<category><![CDATA[Symfony]]></category>

		<category><![CDATA[propel]]></category>

		<category><![CDATA[sessions]]></category>

		<guid isPermaLink="false">http://www.lampjunkie.com/?p=37</guid>
		<description><![CDATA[Previously, I wrote a post on how to store user sessions in a database using Doctrine. I figured that I would follow it up by writing this article to demonstrate how to do the same thing using Propel. The steps are pretty much similar, but with some slight variations.
Step1 - Create your sessions table



&#160;


CREATE TABLE [...]]]></description>
			<content:encoded><![CDATA[<p>Previously, I wrote a <a href="http://www.lampjunkie.com/2008/05/store-symfony-sessions-in-database-with-doctrine/">post on how to store user sessions in a database using Doctrine</a>. I figured that I would follow it up by writing this article to demonstrate how to do the same thing using Propel. The steps are pretty much similar, but with some slight variations.</p>
<h3>Step1 - Create your sessions table</h3>
<div class="geshi no sql">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">CREATE</span> <span class="kw1">TABLE</span> <span class="kw1">IF</span> <span class="kw1">NOT</span> <span class="kw1">EXISTS</span> <span class="st0">`sessions`</span> <span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0">`sess_id`</span> varchar<span class="br0">&#40;</span><span class="nu0">64</span><span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span>,</div>
</li>
<li class="li1">
<div class="de1"><span class="st0">`sess_data`</span> text <span class="kw1">NOT</span> <span class="kw1">NULL</span>,</div>
</li>
<li class="li1">
<div class="de1"><span class="st0">`sess_time`</span> int<span class="br0">&#40;</span><span class="nu0">11</span><span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span>,</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">KEY</span> <span class="st0">`sess_id`</span> <span class="br0">&#40;</span><span class="st0">`sess_id`</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#41;</span> ENGINE<span class="sy0">=</span>MyISAM <span class="kw1">DEFAULT</span> CHARSET<span class="sy0">=</span>latin1;</div>
</li>
</ol>
</div>
<h3>Step 2 - Edit /config/databases.yml</h3>
<p>You need to make sure that you have a connection set up for the session database. So edit /config/databases.yml so it has something like the following:</p>
<div class="geshi no xml">
<ol>
<li class="li1">
<div class="de1">all:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; sessions_db:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; class: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sfPropelDatabase</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; param:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; dsn: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mysql://my_user:my_password@localhost/my_sessions_db</div>
</li>
</ol>
</div>
<h3>Step 3 - Edit the app/config/factories.yml</h3>
<p>You will need to let symfony know that you are going to be using the sfMySQLSessionStorage class to handle your session storage, so edit /app/config/factories.yml:</p>
<div class="geshi no xml">
<ol>
<li class="li1">
<div class="de1">&nbsp; storage:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; class: sfMySQLSessionStorage</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; param:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; db_table: sessions &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Name of the table storing the sessions</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; database: sessions_db &nbsp; &nbsp; # Name of the database connection to use</div>
</li>
</ol>
</div>
<p>Finally, make sure to clear your cache and you should be all set!</p>
<h3>Step 4 - Configure symfony session cleanup, etc.</h3>
<p>Andy, from <a href="http://blog.t8d.de">blog.t8d.de</a> posted some additional findings and links on their blog about some settings that you will want to change within symfony and your php.ini to make sure that your application is performing the proper session cleanup.</p>
<p>Check out:</p>
<ol>
<li><a href="http://robrosenbaum.com/php/howto-disable-session-timeout-in-symfony/">http://robrosenbaum.com/php/howto-disable-session-timeout-in-symfony/</a></li>
<li><a href="http://redotheweb.com/2008/02/01/database-session-handling-and-garbage-collector/">http://redotheweb.com/2008/02/01/database-session-handling-and-garbage-collector/</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.lampjunkie.com/2008/05/store-symfony-sessions-in-database-with-propel/feed/</wfw:commentRss>
		</item>
		<item>
		<title>You know your Website is soooo Web 1.0 When&#8230;</title>
		<link>http://www.lampjunkie.com/2008/05/you-know-your-website-is-sooo-web-1-0-when/</link>
		<comments>http://www.lampjunkie.com/2008/05/you-know-your-website-is-sooo-web-1-0-when/#comments</comments>
		<pubDate>Tue, 20 May 2008 23:33:43 +0000</pubDate>
		<dc:creator>marc</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.lampjunkie.com/?p=35</guid>
		<description><![CDATA[We all have seen them&#8230;those websites that are still caught somewhere in the year 1999 - 2002. Here&#8217;s a checklist to make sure your site isn&#8217;t stuck in Web 1.0 world  
1. Your website&#8217;s pages end in any of the following: .asp, .php3, .php4
2. You have a 30 second Flash Splash Page.
3. You have [...]]]></description>
			<content:encoded><![CDATA[<p>We all have seen them&#8230;those websites that are still caught somewhere in the year 1999 - 2002. Here&#8217;s a checklist to make sure your site isn&#8217;t stuck in Web 1.0 world <img src='http://www.lampjunkie.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>1. Your website&#8217;s pages end in any of the following: .asp, .php3, .php4</p>
<p>2. You have a 30 second Flash Splash Page.</p>
<p>3. You have an all flash site that displays in a popup window.</p>
<p>4. There are only 20+ tables on each page, not one div&#8230;oh and no CSS.</p>
<p>5. You only know how to make a two column layout with frames.</p>
<p>6. Your site says &#8220;Best viewed with Internet Explorer 5.0&#8243; somewhere on it and you really mean it.</p>
<p>7. The closest thing to AJAX is that text in the &lt;blink&gt; or &lt;marquee&gt; tags.</p>
<p>8. Trying to find the site in Google yields nothing since all of your pages contain a single image encompassing your layout and all content.</p>
<p>9. Your streaming video is that animated GIF on your home page.</p>
<p>10. Your idea of social networking is that guestbook CGI script.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lampjunkie.com/2008/05/you-know-your-website-is-sooo-web-1-0-when/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Remove CVS or .svn Directories from the Linux Command Line</title>
		<link>http://www.lampjunkie.com/2008/05/remove-cvs-or-svn-directories-from-the-linux-command-line/</link>
		<comments>http://www.lampjunkie.com/2008/05/remove-cvs-or-svn-directories-from-the-linux-command-line/#comments</comments>
		<pubDate>Mon, 19 May 2008 03:57:16 +0000</pubDate>
		<dc:creator>marc</dc:creator>
		
		<category><![CDATA[Subversion]]></category>

		<category><![CDATA[cvs]]></category>

		<guid isPermaLink="false">http://www.lampjunkie.com/?p=34</guid>
		<description><![CDATA[
So, you copied a bunch of directories from one source controlled project to another and you don&#8217;t want to go through and delete all those CVS or .svn directories by hand? Ok, no problem&#8230;
Below are two snippets that will show you how to recursively remove those directories from the Linux command line in one quick [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.lampjunkie.com/wp-content/themes/mimbo2.1/images/posts/remove-cvs-svn.jpg" alt="Remove CVS or SVN (subversion) directories recursively through command line" class="picleft" /></p>
<p>So, you copied a bunch of directories from one source controlled project to another and you don&#8217;t want to go through and delete all those CVS or .svn directories by hand? Ok, no problem&#8230;</p>
<p>Below are two snippets that will show you how to recursively remove those directories from the Linux command line in one quick instant. Just be sure that if you click-paste these into your shell window, that you are already in the top directory off where you want to delete stuff. I&#8217;ve made the mistake of doing it in the wrong folder without thinking and it automatically deleted all my CVS files for an entire project!</p>
<h3>For CVS:</h3>
<div class="geshi no shell">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">find . -name CVS -prune -exec rm -rf {} \;</div>
</li>
</ol>
</div>
<h3>For SVN:</h3>
<div class="geshi no shell">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">find . -name .svn -prune -exec rm -rf {} \;</div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.lampjunkie.com/2008/05/remove-cvs-or-svn-directories-from-the-linux-command-line/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Getting around the &#8220;Media change: please insert the disk labeled..&#8221; message in Ubuntu</title>
		<link>http://www.lampjunkie.com/2008/05/getting-around-the-media-change-please-insert-disk-labeled-message-in-ubuntu/</link>
		<comments>http://www.lampjunkie.com/2008/05/getting-around-the-media-change-please-insert-disk-labeled-message-in-ubuntu/#comments</comments>
		<pubDate>Sun, 18 May 2008 03:29:34 +0000</pubDate>
		<dc:creator>marc</dc:creator>
		
		<category><![CDATA[Ubuntu]]></category>

		<category><![CDATA[apt-get]]></category>

		<guid isPermaLink="false">http://www.lampjunkie.com/?p=33</guid>
		<description><![CDATA[
So, sometimes when you try to run &#8220;apt-get install&#8221; on Ubuntu, you may get the following message:



&#160;


Media change: please insert the disc labeled



&#160;&#39;Ubuntu-Server 7.10 _Gutsy Gibbon_ - Release i386 (20071016)&#39;



in the drive &#39;/cdrom/&#39; and press enter



Of course this isn&#8217;t a real big problem when you are sitting right next to the computer. However, if it [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.lampjunkie.com/wp-content/themes/mimbo2.1/images/featured/ubuntu-no-cd.jpg" class="picright" /></p>
<p>So, sometimes when you try to run &#8220;apt-get install&#8221; on Ubuntu, you may get the following message:</p>
<div class="geshi no shell">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">Media change: please insert the disc labeled
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;&#39;Ubuntu-Server 7.10 _Gutsy Gibbon_ - Release i386 (20071016)&#39;
</div>
</li>
<li class="li1">
<div class="de1">in the drive &#39;/cdrom/&#39; and press enter</div>
</li>
</ol>
</div>
<p>Of course this isn&#8217;t a real big problem when you are sitting right next to the computer. However, if it happens to you when your server is located in a data center 10 miles away, you probably don&#8217;t want to drive down there to insert a CD rom and head right back home.</p>
<p>Luckily the solution is very easy. You just need to edit your /etc/apt/sources.list configuration file and comment out the line that starts with &#8220;deb cdrom&#8221;. This prevents it from first trying to find the sources on your cd rom. Phew! no need to waste gas!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lampjunkie.com/2008/05/getting-around-the-media-change-please-insert-disk-labeled-message-in-ubuntu/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to set up a Wildcard (catch-all) Virtual Host in Apache</title>
		<link>http://www.lampjunkie.com/2008/05/how-to-set-up-a-wildcard-catch-all-virtual-host-in-apache/</link>
		<comments>http://www.lampjunkie.com/2008/05/how-to-set-up-a-wildcard-catch-all-virtual-host-in-apache/#comments</comments>
		<pubDate>Thu, 15 May 2008 06:28:09 +0000</pubDate>
		<dc:creator>marc</dc:creator>
		
		<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://www.lampjunkie.com/?p=32</guid>
		<description><![CDATA[Suppose that you need to set up a virtual host in Apache that catches all un-matched traffic coming in to your server. There are a number of uses for this, but the main idea is that you have a number of other virtual hosts set up, but you want anything that doesn&#8217;t match those to [...]]]></description>
			<content:encoded><![CDATA[<p>Suppose that you need to set up a virtual host in Apache that catches all un-matched traffic coming in to your server. There are a number of uses for this, but the main idea is that you have a number of other virtual hosts set up, but you want anything that doesn&#8217;t match those to forward to a specific virtual host.</p>
<p>Here is an excerpt from an example httpd.conf file:</p>
<div class="geshi no conf">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&lt;VirtualHost *:80&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; ServerName default
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; ServerAlias *
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; ServerAlias somepreviewdomain.com
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; DocumentRoot /home/me/my_app/html
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &lt;Directory &quot;/home/me/my_app/html&quot;&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; Options Indexes FollowSymLinks
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; AllowOverride All
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; Allow from All
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &lt;/Directory&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&lt;/VirtualHost&gt;</div>
</li>
</ol>
</div>
<p>Just be sure to make this the last virtual host entry in your httpd.conf file, so that any other vhosts before that work as they should.</p>
<p>In this example I also included an alias for an actual domain so that the vitualhost can still be accessed by an actual domain as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lampjunkie.com/2008/05/how-to-set-up-a-wildcard-catch-all-virtual-host-in-apache/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Get a PHP Script&#8217;s Own Linux PID (Process Id)</title>
		<link>http://www.lampjunkie.com/2008/05/get-a-php-scripts-own-linux-pid-process-id/</link>
		<comments>http://www.lampjunkie.com/2008/05/get-a-php-scripts-own-linux-pid-process-id/#comments</comments>
		<pubDate>Thu, 15 May 2008 00:52:17 +0000</pubDate>
		<dc:creator>marc</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[pid]]></category>

		<guid isPermaLink="false">http://www.lampjunkie.com/?p=30</guid>
		<description><![CDATA[Previously, I wrote this article on how to check the status of a known system PID from PHP. I figured that I would follow it up with another short article on how to determine the process id of a running PHP script from within itself. Many google searches seem to have led people to the [...]]]></description>
			<content:encoded><![CDATA[<p>Previously, <a href="http://www.lampjunkie.com/2008/04/check-if-linux-process-is-still-alive-from-php/">I wrote this article</a> on how to check the status of a known system PID from PHP. I figured that I would follow it up with another short article on how to determine the process id of a running PHP script from within itself. Many google searches seem to have led people to the previous article, so I want to round everything out for those that need to get the PID in the first place.</p>
<p>So, why would you want to know the PID of a running PHP script anyways?</p>
<p>Occasionally I have written some specific jobs that are to run in an infinite loop to handle data processing on a server. Since these types of scripts get fired up once in the background, I need to be able to check the status from another PHP application that is managing the state of several of these looping processes.</p>
<p>Basically I need to get the PHP script&#8217;s PID from itself and then store that somewhere (database, memcache, text file, etc) so that the other application can check the status, etc.</p>
<p>So in order to achieve this, all we have to do is this:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// get my pid!</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$pid</span> <span class="sy0">=</span> <span class="kw3">getmypid</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// do something with it (i.e. store somewhere for later retrieval)&#8230;.</span></div>
</li>
</ol>
</div>
<p>Wow, that was simple! <a href="http://www.lampjunkie.com/2008/04/check-if-linux-process-is-still-alive-from-php/">Check out my previous article</a> to see how you can check on the PID from another script once you know what it is.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lampjunkie.com/2008/05/get-a-php-scripts-own-linux-pid-process-id/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Symfony Bulk Update with Propel</title>
		<link>http://www.lampjunkie.com/2008/05/symfony-bulk-update-with-propel/</link>
		<comments>http://www.lampjunkie.com/2008/05/symfony-bulk-update-with-propel/#comments</comments>
		<pubDate>Mon, 12 May 2008 23:18:51 +0000</pubDate>
		<dc:creator>marc</dc:creator>
		
		<category><![CDATA[Symfony]]></category>

		<category><![CDATA[propel]]></category>

		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://www.lampjunkie.com/?p=29</guid>
		<description><![CDATA[Here is a quick example of how to do a bulk update with Propel within symfony. This is based on this code snippet on the symfony site. I thought it was extremely useful, so I wanted to post it as an easy reference for myself and others.
Suppose we had a query which looked like this:



&#160;


UPDATE [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a quick example of how to do a bulk update with Propel within symfony. This is based on <a href="http://www.symfony-project.org/snippets/snippet/50" target="_blank">this code snippet on the symfony site</a>. I thought it was extremely useful, so I wanted to post it as an easy reference for myself and others.</p>
<p>Suppose we had a query which looked like this:</p>
<div class="geshi no sql">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">UPDATE</span> articles <span class="kw1">SET</span> <span class="kw1">STATUS</span> <span class="sy0">=</span> <span class="nu0">0</span> <span class="kw1">WHERE</span> user_id <span class="sy0">=</span> <span class="nu0">10</span>;</div>
</li>
</ol>
</div>
<p>Here is how we would translate it into symfony/propel terms:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// set the select condition criteria</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$c</span> <span class="sy0">=</span> <span class="kw2">new</span> Criteria<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$c</span><span class="sy0">-&gt;</span><span class="me1">add</span><span class="br0">&#40;</span>ArticlePeer<span class="sy0">::</span><span class="me2">USER_ID</span><span class="sy0">,</span> <span class="nu0">10</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// set the update criteria</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$update</span> <span class="sy0">=</span> <span class="kw2">new</span> Criteria<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$update</span><span class="sy0">-&gt;</span><span class="me1">add</span><span class="br0">&#40;</span>ArticlePeer<span class="sy0">::</span><span class="me2">STATUS</span><span class="sy0">,</span> <span class="nu0">0</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// we need the connection for update, so get default connection</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$con</span> <span class="sy0">=</span> Propel<span class="sy0">::</span><span class="me2">getConnection</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// finally, do the update</span></div>
</li>
<li class="li1">
<div class="de1">BasePeer<span class="sy0">::</span><span class="me2">doUpdate</span><span class="br0">&#40;</span><span class="re1">$c</span><span class="sy0">,</span> <span class="re1">$update</span><span class="sy0">,</span> <span class="re1">$con</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
<p>We are just creating the first criteria to find all the objects that we want to select and then update. Then creating the second one that specifies which values we are updating. Easy!</p>
<p>The main thing to notice is that we are using the &#8216;BasePeer&#8217; class, so you need to make sure that you explicitly pass in a connection, otherwise it won&#8217;t work as expected!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lampjunkie.com/2008/05/symfony-bulk-update-with-propel/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Append Revision Number to CSS and JS Includes in Symfony</title>
		<link>http://www.lampjunkie.com/2008/05/append-revision-number-to-css-and-js-includes-in-symfony/</link>
		<comments>http://www.lampjunkie.com/2008/05/append-revision-number-to-css-and-js-includes-in-symfony/#comments</comments>
		<pubDate>Wed, 07 May 2008 17:01:13 +0000</pubDate>
		<dc:creator>marc</dc:creator>
		
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.lampjunkie.com/?p=20</guid>
		<description><![CDATA[I&#8217;m sure many of us have had a similar experience such as the following. You push out a kick-ass update to a client&#8217;s website full of brand new design changes to the main.css file or some funkalicious AJAX features to your javascript files. However, later in the day you get a frantic call from the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sure many of us have had a similar experience such as the following. You push out a kick-ass update to a client&#8217;s website full of brand new design changes to the main.css file or some funkalicious AJAX features to your javascript files. However, later in the day you get a frantic call from the client and it goes something like this:</p>
<p>Client: &#8220;There is a problem with the website!! It looks all messed up! It needs to be fixed right away! We are probably loosing customers!&#8221;</p>
<p>You think for a second a realize that their browser must be caching some old version of that main.css file, so it&#8217;s not displaying the new design correctly. So the conversation continues:</p>
<p>You: &#8220;Oh your browser must have the old stylesheet cached..Just press F5 in your browser.&#8221;</p>
<p>Client: &#8220;What&#8217;s F5? What&#8217;s my browser? Oh you mean the Internet Explorer thing?&#8221;</p>
<p>I don&#8217;t know about you, but this is a conversation that I would like to avoid and never have again for the rest of my life. So luckily the solution is pretty easy in symfony.</p>
<h3>The problem:</h3>
<p>The problem is pretty simple. Sometimes certain browsers are caching the css or js files for too long, even after they have been updated on the server. So even after the files are updated on the server, visitors who have already visited the website are actually using the old version of the file files that have been cached in their browsers. Naturally this can mess up alot of things if it&#8217;s not taken care of.</p>
<h3>The basic solution:</h3>
<p>In general terms, the solution to this is to let the browser know that there is a new version of the file by changing the file name. In the most basic way you could literally change the filename (main.css to main_1.css), but that&#8217;s obviously not the best way to do it. The better way to do it is by appending a version or revision number to the end of the file name as a parameter. So you would have something like this in your page head:</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&lt;script type=&quot;text/javascript&quot; src=&quot;common.js?v=20080423&quot;&gt;&lt;/script&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen&quot; href=&quot;main.css?v=20080423&quot; /&gt;</div>
</li>
</ol>
</div>
<p>In the example above, I am just appending the current date to the end of the file. So the basic idea is that your are putting the revision date of a code push to all of the static files that get included into your main layout file.</p>
<h3>The symfony solution:</h3>
<p>Now there is a way that we can change around a few things in our symfony project to make this change easy in a DRY (don&#8217;t repeat yourself) fashion.</p>
<p>The first step is to override the AssetHelper.php file that is within the symfony core files. All you have to do is copy this file from {SYMFONY_LIB_DIR}/helper/ to {YOUR_PROJECT_DIR}/lib/helper/AssetHelper.php.</p>
<p>Now you just need to add two small changes to this helper file. We are just going to add a constant called REVISION along with a parameter (?v=) and append them to the file names.</p>
<p>First change the get_javascripts() function so that it looks like the following:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> get_javascripts<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re1">$response</span> <span class="sy0">=</span> sfContext<span class="sy0">::</span><span class="me2">getInstance</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">-&gt;</span><span class="me1">getResponse</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re1">$response</span><span class="sy0">-&gt;</span><span class="me1">setParameter</span><span class="br0">&#40;</span><span class="st0">&#39;javascripts_included&#39;</span><span class="sy0">,</span> <span class="kw2">true</span><span class="sy0">,</span> <span class="st0">&#39;symfony/view/asset&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re1">$already_seen</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re1">$html</span> <span class="sy0">=</span> <span class="st0">&#39;&#39;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">foreach</span> <span class="br0">&#40;</span><span class="kw3">array</span><span class="br0">&#40;</span><span class="st0">&#39;first&#39;</span><span class="sy0">,</span> <span class="st0">&#39;&#39;</span><span class="sy0">,</span> <span class="st0">&#39;last&#39;</span><span class="br0">&#41;</span> <span class="kw1">as</span> <span class="re1">$position</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">foreach</span> <span class="br0">&#40;</span><span class="re1">$response</span><span class="sy0">-&gt;</span><span class="me1">getJavascripts</span><span class="br0">&#40;</span><span class="re1">$position</span><span class="br0">&#41;</span> <span class="kw1">as</span> <span class="re1">$files</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><span class="kw3">is_array</span><span class="br0">&#40;</span><span class="re1">$files</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$files</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="re1">$files</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">foreach</span> <span class="br0">&#40;</span><span class="re1">$files</span> <span class="kw1">as</span> <span class="re1">$file</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$file</span> <span class="sy0">=</span> javascript_path<span class="br0">&#40;</span><span class="re1">$file</span><span class="br0">&#41;</span> <span class="sy0">.</span> <span class="st0">&quot;?v=&quot;</span> <span class="sy0">.</span> REVISION<span class="sy0">;</span> <span class="co1">// our revision addition</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw3">isset</span><span class="br0">&#40;</span><span class="re1">$already_seen</span><span class="br0">&#91;</span><span class="re1">$file</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="kw1">continue</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$already_seen</span><span class="br0">&#91;</span><span class="re1">$file</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="nu0">1</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$html</span> <span class="sy0">.=</span> javascript_include_tag<span class="br0">&#40;</span><span class="re1">$file</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">return</span> <span class="re1">$html</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>Secondly, change the get_stylesheets() function so that it looks like this:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> get_stylesheets<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re1">$response</span> <span class="sy0">=</span> sfContext<span class="sy0">::</span><span class="me2">getInstance</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">-&gt;</span><span class="me1">getResponse</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re1">$response</span><span class="sy0">-&gt;</span><span class="me1">setParameter</span><span class="br0">&#40;</span><span class="st0">&#39;stylesheets_included&#39;</span><span class="sy0">,</span> <span class="kw2">true</span><span class="sy0">,</span> <span class="st0">&#39;symfony/view/asset&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re1">$already_seen</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re1">$html</span> <span class="sy0">=</span> <span class="st0">&#39;&#39;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">foreach</span> <span class="br0">&#40;</span><span class="kw3">array</span><span class="br0">&#40;</span><span class="st0">&#39;first&#39;</span><span class="sy0">,</span> <span class="st0">&#39;&#39;</span><span class="sy0">,</span> <span class="st0">&#39;last&#39;</span><span class="br0">&#41;</span> <span class="kw1">as</span> <span class="re1">$position</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">foreach</span> <span class="br0">&#40;</span><span class="re1">$response</span><span class="sy0">-&gt;</span><span class="me1">getStylesheets</span><span class="br0">&#40;</span><span class="re1">$position</span><span class="br0">&#41;</span> <span class="kw1">as</span> <span class="re1">$files</span> <span class="sy0">=&gt;</span> <span class="re1">$options</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><span class="kw3">is_array</span><span class="br0">&#40;</span><span class="re1">$files</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$files</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="re1">$files</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">foreach</span> <span class="br0">&#40;</span><span class="re1">$files</span> <span class="kw1">as</span> <span class="re1">$file</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$file</span> <span class="sy0">=</span> stylesheet_path<span class="br0">&#40;</span><span class="re1">$file</span><span class="br0">&#41;</span> <span class="sy0">.</span> <span class="st0">&quot;?v=&quot;</span> <span class="sy0">.</span> REVISION<span class="sy0">;</span> <span class="co1">// our revision addition</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw3">isset</span><span class="br0">&#40;</span><span class="re1">$already_seen</span><span class="br0">&#91;</span><span class="re1">$file</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="kw1">continue</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$already_seen</span><span class="br0">&#91;</span><span class="re1">$file</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="nu0">1</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">$html</span> <span class="sy0">.=</span> stylesheet_tag<span class="br0">&#40;</span><span class="re1">$file</span><span class="sy0">,</span> <span class="re1">$options</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">return</span> <span class="re1">$html</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>Finally you just need to define that REVISION constant somewhere. It&#8217;s up to you where to put it. But for simplicity sake, let&#8217;s just say that you put it in the front controller for your frontend application (/web/index.php). You would have something like this in the beginning of the file:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// set the revision global variable</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">define</span><span class="br0">&#40;</span><span class="st0">&#39;REVISION&#39;</span><span class="sy0">,</span> <span class="st0">&#39;2008042300&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
<p>A better solution would probably be to create a system that stores the revision number in a text file that gets included somewhere in your application. Then this file can be automatically updated through your application when you make updates. Another possible approach would be to update the file through a build tool such as Ant, or to extend the symfony sync task so that it automatically updates when you do a code push.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lampjunkie.com/2008/05/append-revision-number-to-css-and-js-includes-in-symfony/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
  
