<?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>SayNoToFlash</title>
	<atom:link href="http://www.saynotoflash.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.saynotoflash.com</link>
	<description>PHP, Symfony, Web Development</description>
	<lastBuildDate>Tue, 16 Mar 2010 12:21:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Network Merchants API Script</title>
		<link>http://www.saynotoflash.com/archives/network-merchants-api-script/</link>
		<comments>http://www.saynotoflash.com/archives/network-merchants-api-script/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 19:08:32 +0000</pubDate>
		<dc:creator>jestep</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.saynotoflash.com/?p=447</guid>
		<description><![CDATA[Have just completed a Network Merchants API class. This class utilizes the Network Merchants credit card and electronic check processing API. It also includes the customer vault API which allows merchants to securely store their customer&#8217;s credit card and bank account information in Network Merchant&#8217;s secure customer vault.
Go to the Network Merchants API PHP Class [...]]]></description>
			<content:encoded><![CDATA[<p>Have just completed a Network Merchants API class. This class utilizes the Network Merchants credit card and electronic check processing API. It also includes the customer vault API which allows merchants to securely store their customer&#8217;s credit card and bank account information in Network Merchant&#8217;s secure customer vault.</p>
<p><a href="http://www.saynotoflash.com/scripts/network-merchants-api-php-class-script/">Go to the Network Merchants API PHP Class &raquo;</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saynotoflash.com/archives/network-merchants-api-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google chart over HTTPS/SSL</title>
		<link>http://www.saynotoflash.com/archives/google-chart-over-httpsssl/</link>
		<comments>http://www.saynotoflash.com/archives/google-chart-over-httpsssl/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 16:17:14 +0000</pubDate>
		<dc:creator>jestep</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.saynotoflash.com/?p=403</guid>
		<description><![CDATA[The google charts API does not support the https protocol. If your website is being delivered through a secure connection, the chart will cause a SSL error. Here's a quick way to deliver google chart images over ssl.
To start off with, the chart image must be delivered from a secure connection. Google doesn't allow this [...]]]></description>
			<content:encoded><![CDATA[<p>The google charts API does not support the https protocol. If your website is being delivered through a secure connection, the chart will cause a SSL error. Here's a quick way to deliver google chart images over ssl.</p>
<p>To start off with, the chart image must be delivered from a secure connection. Google doesn't allow this plain and simple, so we need to figure out how to host it from our own site. We accomplish this by fetching the image from google using the standard API, writing it to a file, and then calling it on our own script. We basically make a image handling proxy.</p>
<p>Let's take a simple google chart to experiment with.</p>
<p><img src="http://chart.apis.google.com/chart?chs=500x50&#038;chf=bg,s,ffffff&#038;cht=ls&#038;chd=t:23.52,20.58,26.47,23.52,23.52,23.52,100.00,0.00,23.52,23.52,27.94,20.58,23.52&#038;chco=0066ff" alt="" /></p>
<div class="igBar"><span id="lphp-4"><a href="#" onclick="javascript:showPlainTxt('php-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-4">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$chart_image</span> = <span style="color:#FF0000;">'http://chart.apis.google.com/chart?chs=500x50&amp;chf=bg,s,ffffff&amp;cht=ls&amp;chd=t:23.52,20.58,26.47,23.52,23.52,23.52,100.00,0.00,23.52,23.52,27.94,20.58,23.52&amp;chco=0066ff'</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Next we need to make a function to fetch and save the google chart locally. It will check the chart against the local copy and save it if the chart doesn't exist, or the image has changed. This way we aren't re-writing the same chart on every request, but if the chart changes, it will be updated appropriately.</p>
<div class="igBar"><span id="lphp-5"><a href="#" onclick="javascript:showPlainTxt('php-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-5">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public <a href="http://www.php.net/static"><span style="color:#000066;">static</span></a> <span style="color:#000000; font-weight:bold;">function</span> saveImage<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$chart_url</span>,<span style="color:#0000FF;">$path</span>,<span style="color:#0000FF;">$file_name</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>!<a href="http://www.php.net/file_exists"><span style="color:#000066;">file_exists</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$path</span>.<span style="color:#0000FF;">$file_name</span><span style="color:#006600; font-weight:bold;">&#41;</span> || <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/md5_file"><span style="color:#000066;">md5_file</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$path</span>.<span style="color:#0000FF;">$file_name</span><span style="color:#006600; font-weight:bold;">&#41;</span> != <a href="http://www.php.net/md5_file"><span style="color:#000066;">md5_file</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$chart_url</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; file_put_contents<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$path</span>.<span style="color:#0000FF;">$file_name</span>,<a href="http://www.php.net/file_get_contents"><span style="color:#000066;">file_get_contents</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$chart_url</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$file_name</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Lastly we tie it all together so that it is usable in our application. Im using this within a class, but this could just be used as a function as well. Your image directory will need to be writable for this to work.</p>
<div class="igBar"><span id="lphp-6"><a href="#" onclick="javascript:showPlainTxt('php-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-6">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public <span style="color:#000000; font-weight:bold;">function</span> doSomething<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$local_image_path</span> = <span style="color:#FF0000;">'/path/to/images/charts/'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$image_name</span> = <span style="color:#FF0000;">'some_chart_image.png'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$chart_url</span> = <span style="color:#FF0000;">'http://chart.apis.google.com/chart?chs=500x50&amp;chf=bg,s,ffffff&amp;cht=ls&amp;chd=t:23.52,20.58,26.47,23.52,23.52,23.52,100.00,0.00,23.52,23.52,27.94,20.58,23.52&amp;chco=0066ff'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$image</span> = self::<span style="color:#006600;">saveImage</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$chart_url</span> ,<span style="color:#0000FF;">$local_image_path</span>,<span style="color:#0000FF;">$image_name</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>You'll need to implement your own error handling, and adjust this to meet the paths and specifics of your server, but the image can now be called from:<br />
&lt;img src=&quot;/images/charts/some_chart_image.png&quot; alt=&quot;&quot; /&gt;</p>
<p>If you need help creating your base chart image, <a href="http://www.clabberhead.com/googlechartgenerator.html">this tool is a great place to start</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saynotoflash.com/archives/google-chart-over-httpsssl/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Firefox 3 broken images breaking SSL</title>
		<link>http://www.saynotoflash.com/archives/firefox-3-broken-images-breaking-ssl/</link>
		<comments>http://www.saynotoflash.com/archives/firefox-3-broken-images-breaking-ssl/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 19:55:54 +0000</pubDate>
		<dc:creator>jestep</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.saynotoflash.com/?p=390</guid>
		<description><![CDATA[After battling a SSL error: "Warning contains unauthenticated content" in Firefox 3.5 for the past few days, I finally figured out what the problem was. 
Unlike Internet Explorer and older Firefox versions, Firefox 3.5 gives this error if there are any missing images on a webpage. Meaning, that if an image link or css reference [...]]]></description>
			<content:encoded><![CDATA[<p>After battling a SSL error: "Warning contains unauthenticated content" in Firefox 3.5 for the past few days, I finally figured out what the problem was. </p>
<p>Unlike Internet Explorer and older Firefox versions, Firefox 3.5 gives this error if there are any missing images on a webpage. Meaning, that if an image link or css reference is to a non-existent image, Firefox warns that the page is not secure. To my knowledge, Firefox versions previous to 3.something, did not behave like this. Internet explorer, Google Chrome, Safari, and every other non-Firefox browser that I tested don't care about broken images. Not to say that Firefox is wrong, but this made the problem more difficult to diagnose because it couldn't be reproduced in another program.</p>
<p>The difficulty in diagnosing this, is that background images that don't load also don't show up in the <em>page info</em> section on Firefox. Firebug didn't provide any immediately useful information, and there was no documentation that I could find regarding this situation. </p>
<p><img src="http://www.saynotoflash.com/wp-content/uploads/2009/09/ssl-debug1.png" alt="ssl-debug" title="ssl-debug" width="602" height="485" class="alignnone size-full wp-image-399" /></p>
<p>After several hours of searching, I realized that there was a small broken background image. Deleting or correcting the image path immediately corrected the certificate error.</p>
<p>Anyway, if anyone has been pulling out their hair trying to diagnose a mystery ssl error, and this is a possibility, definitely look into your image paths.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saynotoflash.com/archives/firefox-3-broken-images-breaking-ssl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Symfony 1.2 redirect specific modules and actions to HTTPS (SSL)</title>
		<link>http://www.saynotoflash.com/archives/symfony-1-2-redirect-specific-modules-and-actions-to-https-ssl/</link>
		<comments>http://www.saynotoflash.com/archives/symfony-1-2-redirect-specific-modules-and-actions-to-https-ssl/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 22:24:16 +0000</pubDate>
		<dc:creator>jestep</dc:creator>
				<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.saynotoflash.com/?p=370</guid>
		<description><![CDATA[Post Symfony 1.1, the sfSslRequirementPlugin will no longer work.
Having needed a way to force a SSL connection for certain pages, I modified a few scripts that I found online, and created a very simple filter to handle this. This was inspired by this script, and the unacceptably poor example in the Symfony 1.2 book.
To start [...]]]></description>
			<content:encoded><![CDATA[<p>Post Symfony 1.1, the <a href="http://www.symfony-project.org/plugins/sfSslRequirementPlugin">sfSslRequirementPlugin</a> will no longer work.</p>
<p>Having needed a way to force a SSL connection for certain pages, I modified a few scripts that I found online, and created a very simple filter to handle this. This was inspired by <a href="http://james.mcglinn.org/2006/10/ssl-redirect-filter-for-symfony/">this script</a>, and the unacceptably poor <a href="http://www.symfony-project.org/book/1_2/06-Inside-the-Controller-Layer#chapter_06_sub_sample_filters">example in the Symfony 1.2 book</a>.</p>
<p>To start off with, we need to modify our app.yml file to specify what modules and/or actions need to be secure. Leave the action completely blank if you want the entire module secure. Also change <strong>ignore_non_secure</strong> to true if you don't care if non specified pages are server over a ssl connection. Basically, from the app.yml below, setting this to false, will redirect any module/action to the non-secure version if it is not specifically defined under <strong>secure_actions</strong>. Setting it to true will allow a user to request any page over https, even if it is not listed in app.yml. Let me know if this is confusing in any way.</p>
<div class="igBar"><span id="lphp-10"><a href="#" onclick="javascript:showPlainTxt('php-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-10">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//app.yml</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">all:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; ssl:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ignore_non_secure: <span style="color:#000000; font-weight:bold;">false</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; secure_actions:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; - <span style="color:#006600; font-weight:bold;">&#123;</span> module: shopping_cart<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; - <span style="color:#006600; font-weight:bold;">&#123;</span> module: services&nbsp; action: apply<span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Next we add this filter. Save this under MyProject/apps/MyApp/lib/sfSslFilter.php</p>
<div class="igBar"><span id="lphp-11"><a href="#" onclick="javascript:showPlainTxt('php-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-11">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> sslFilter extends sfFilter</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; * Execute filter</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; *</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; * @param FilterChain $filterChain The symfony filter chain</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> execute <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$filterChain</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$context</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">getContext</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$request</span> = <span style="color:#0000FF;">$context</span>-&gt;<span style="color:#006600;">getRequest</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$ssl_actions</span> = sfConfig::<span style="color:#006600;">get</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'app_ssl_secure_actions'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$allow_ssl</span> = sfConfig::<span style="color:#006600;">get</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'app_ssl_ignore_non_secure'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#008000;">/*</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Uncomment For Debugging</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* echo '&lt;pre&gt;';</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* print_r($ssl_actions);</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* echo '&lt;/pre&gt;';</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* exit();</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>!<span style="color:#0000FF;">$request</span>-&gt;<span style="color:#006600;">isSecure</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">//Redirect to the Secure Url</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">//If the module and/or action match $ssl_actions set in app.yml</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">foreach</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$ssl_actions</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$action</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$action</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'module'</span><span style="color:#006600; font-weight:bold;">&#93;</span> == <span style="color:#0000FF;">$context</span>-&gt;<span style="color:#006600;">getModuleName</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> &amp;&amp; !<span style="color:#0000FF;">$action</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'action'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">//The entire module needs to be secure</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">//Redired no matter what the action is.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$secure_url</span> = <a href="http://www.php.net/str_replace"><span style="color:#000066;">str_replace</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'http'</span>, <span style="color:#FF0000;">'https'</span>, <span style="color:#0000FF;">$request</span>-&gt;<span style="color:#006600;">getUri</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$context</span>-&gt;<span style="color:#006600;">getController</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>-&gt;<span style="color:#006600;">redirect</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$secure_url</span>, <span style="color:#CC66CC;color:#800000;">0</span> , <span style="color:#CC66CC;color:#800000;">301</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#616100;">else</span> <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$action</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'module'</span><span style="color:#006600; font-weight:bold;">&#93;</span> == <span style="color:#0000FF;">$context</span>-&gt;<span style="color:#006600;">getModuleName</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> &amp;&amp; <span style="color:#0000FF;">$action</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'action'</span><span style="color:#006600; font-weight:bold;">&#93;</span> == <span style="color:#0000FF;">$context</span>-&gt;<span style="color:#006600;">getActionName</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">//Redirect if the module and action need to be secure</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$secure_url</span> = <a href="http://www.php.net/str_replace"><span style="color:#000066;">str_replace</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'http'</span>, <span style="color:#FF0000;">'https'</span>, <span style="color:#0000FF;">$request</span>-&gt;<span style="color:#006600;">getUri</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$context</span>-&gt;<span style="color:#006600;">getController</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>-&gt;<span style="color:#006600;">redirect</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$secure_url</span>, <span style="color:#CC66CC;color:#800000;">0</span> , <span style="color:#CC66CC;color:#800000;">301</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#616100;">else</span> <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$request</span>-&gt;<span style="color:#006600;">isSecure</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> &amp;&amp; !<span style="color:#0000FF;">$allow_ssl</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$redirect</span> = <span style="color:#000000; font-weight:bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">//Redirect to the Non-Secure Url</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">//If the module and/or action are not in $ssl_actions set in app.yml</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">foreach</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$ssl_actions</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$action</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$action</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'module'</span><span style="color:#006600; font-weight:bold;">&#93;</span> == <span style="color:#0000FF;">$context</span>-&gt;<span style="color:#006600;">getModuleName</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> &amp;&amp; !<span style="color:#0000FF;">$action</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'action'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> || <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$action</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'module'</span><span style="color:#006600; font-weight:bold;">&#93;</span> == <span style="color:#0000FF;">$context</span>-&gt;<span style="color:#006600;">getModuleName</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> &amp;&amp; <span style="color:#0000FF;">$action</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'action'</span><span style="color:#006600; font-weight:bold;">&#93;</span> == <span style="color:#0000FF;">$context</span>-&gt;<span style="color:#006600;">getActionName</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$redirect</span> = <span style="color:#000000; font-weight:bold;">false</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$redirect</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#0000FF;">$non_secure_url</span> = <a href="http://www.php.net/str_replace"><span style="color:#000066;">str_replace</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'https'</span>, <span style="color:#FF0000;">'http'</span>, <span style="color:#0000FF;">$request</span>-&gt;<span style="color:#006600;">getUri</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#616100;">return</span> <span style="color:#0000FF;">$context</span>-&gt;<span style="color:#006600;">getController</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>-&gt;<span style="color:#006600;">redirect</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$non_secure_url</span>, <span style="color:#CC66CC;color:#800000;">0</span> , <span style="color:#CC66CC;color:#800000;">301</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$filterChain</span>-&gt;<span style="color:#006600;">execute</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Finally, add to the MyProject/apps/MyApp/config/filters.yml file:</p>
<div class="igBar"><span id="lphp-12"><a href="#" onclick="javascript:showPlainTxt('php-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-12">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sslFilter:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#000000; font-weight:bold;">class</span>:&nbsp; sslFilter </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Clear the cache <em>(symfony cc)</em>, and there you have it. Let me know if you have a better or different way of dealing with this on a per-module or per-action basis. Hopefully sfSslRequirementPlugin will get ported to work with Symfony 1.2, as the method above will not alter routes on your application.</p>
<p>Additionally, I specifically used 301 redirects to make this more search engine friendly, in case Google or another bot gets on a ssl page. This will help prevent getting duplicate pages indexed due to http and https versions of the same page.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saynotoflash.com/archives/symfony-1-2-redirect-specific-modules-and-actions-to-https-ssl/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>20 Great non-PHP Tools for PHP Developers</title>
		<link>http://www.saynotoflash.com/archives/20-great-non-php-tools-for-php-developers/</link>
		<comments>http://www.saynotoflash.com/archives/20-great-non-php-tools-for-php-developers/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 22:47:18 +0000</pubDate>
		<dc:creator>jestep</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.saynotoflash.com/?p=117</guid>
		<description><![CDATA[By nature I always strive to find more efficient, and better ways to perform tasks. There are a number of development tools that I use that really help me develop better applications in a reduced amount of time. These are the tools I use every day for web development.

Cheat Sheets:
1.) DZone has created professional Cheat [...]]]></description>
			<content:encoded><![CDATA[<p>By nature I always strive to find more efficient, and better ways to perform tasks. There are a number of development tools that I use that really help me develop better applications in a reduced amount of time. These are the tools I use every day for web development.<br />
<span id="more-117"></span><br />
<h3>Cheat Sheets:</h3>
<p><strong>1.)</strong> DZone has created professional <a href="http://refcardz.dzone.com/">Cheat Sheets</a> for a number of PHP, and web development topics. These can save a ton of time from digging into a manual or doing a search online. These aren't by any means the only cheat sheets out there, but you will find PHP, MySQL, XML, ASP, Java, Design Patterns, Joomla, and about 50 more easy to read, well designed cheat sheets.</p>
<p><img src="http://www.saynotoflash.com/wp-content/uploads/2009/08/php-cheat.png" alt="php-cheat" title="php-cheat" width="550" height="440" class="aligncenter size-full wp-image-335" /></p>
<h3>IDE:</h3>
<p><strong>2.)</strong> <img src="http://www.saynotoflash.com/wp-content/uploads/2009/08/NetBeans-sync.png" alt="NetBeans-sync" title="NetBeans-sync" width="300" height="86" class="alignleft size-full wp-image-336" /><a href="http://www.netbeans.org/">NetBeans</a> is an IDE that stands out above all others. It's completely free. It offers a built-in FTP client <em>(Far superior to Dreamweaver)</em> or supports subversion publishing. It is very small, fast, and has many built-in features that help create better code, more efficiently. Netbeans is hands down the best IDE, with the fewest bugs (Not completely bug free), and virtually no learning curve (Try that Eclipse...), that I've used.</p>
<p>If you are holding on to Dreamweaver because of the FTP, or some other function that Eclipse PDE or Zend Studio is lacking, I urge you to take a look at Netbeans. When I'm not using SVN, I can save the file I'm working on and it is automatically uploaded to the web or testing server. Try it, you won't be disappointed.</p>
<h3>Database Management:</h3>
<p><strong>3.)</strong> <a href="http://www.navicat.com/">Navicat</a> is by far the best database GUI, and my experience the best tool for database management on the market. Premiumsoft offers MySQL, PostgreSQL, Oracle versions, and now a single package that includes all three. Navicat provides an intelligent and efficient way to create, backup, and manage complex MySQL databases. It allows multiple methods of connecting, including a SSH tunnel, which protects your database from being accessed publicly. Apart from a good IDE, this is the #1 tool in my development toolbox. Navicat also offers a custom <a href="http://www.navicat.com/en/products/report_builder.html">report building application</a>, which can export data into Excel, Access, Text, XML, Lotus 123, or through an ODBC connection. This software is not free but they do offer a free 30 day trial. If you do a lot of database management, this software will probably pay for itself in time the first week you use it.</p>
<p><img src="http://www.saynotoflash.com/wp-content/uploads/2009/08/navicat.png" alt="navicat" title="navicat" width="500" height="378" class="aligncenter size-full wp-image-315" /></p>
<p><strong>4.)</strong> <a href="http://www.webyog.com/">Monyog</a> is a fantastic real-time MySQL reporting program. It offers visual graphs of a database's performance, and stats on just about everything that can be measured in MySQL. It is an excellent way to monitor a Database and is  indispensable for benchmarking and optimizing MySQL performance.</p>
<p><img src="http://www.saynotoflash.com/wp-content/uploads/2009/08/monyog.png" alt="monyog" title="monyog" width="522" height="429" class="aligncenter size-full wp-image-328" /></p>
<p><strong>5.)</strong> <a href="http://dev.mysql.com/workbench/">MySQL Workbench</a> is a free MySQL development program which can create visual diagrams of a database's structure, among many other features. This can be very important when you are working with large or just new databases. A picture can be worth much more than a thousand words when you are diving into a complex database.</p>
<p>Here's a diagram of a moderately complex database, which could take a lot of time to understand without anything but the table structure.</p>
<p><img src="http://www.saynotoflash.com/wp-content/uploads/2009/08/mysql-workbench-diagram.png" alt="mysql-workbench-diagram" title="mysql-workbench-diagram" width="500" height="171" class="aligncenter size-full wp-image-299" /></p>
<p><strong>6.)</strong> <a href="http://www.dpriver.com/pp/sqlformat.htm">SQL Code Formatter</a> is a quick tool that formats SQL code into an easy to read format. This tool can be indispensable when you are debugging other developers code, or trying to break-down a massive jumbled SQL statement.</p>
<p><strong>Turn junk like this:</strong><br />
SELECT users.id, users.name, users.address, billing.order_num, billing.subtotal, billing.shipping, billing.tax, SUM(billing.subtotal + billing.shipping + billing.tax) AS total FROM users LEFT JOIN billing ON users.id = billing.user_id WHERE billing.order_date &gt; '2009-07-31' AND billing.complete = '1'</p>
<p><strong>Into this <em>(example query may not make any sense)</em>:</strong></p>
<div class="igBar"><span id="lsql-14"><a href="#" onclick="javascript:showPlainTxt('sql-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-14">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span> users.id,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;users.name,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;users.address,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;billing.order_num,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;billing.subtotal,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;billing.shipping,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;billing.tax,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;Sum<span style="color:#006600; font-weight:bold;">&#40;</span>billing.subtotal + billing.shipping + billing.tax<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> total</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">FROM</span>&nbsp; &nbsp;users</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">JOIN</span> billing</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">ON</span> users.id = billing.user_id</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">WHERE</span>&nbsp; billing.order_date&gt; <span style="color: #ff0000;">'2009-07-31'</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #993333; font-weight: bold;">AND</span> billing.complete = <span style="color: #ff0000;">'1'</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h3>Debugging:</h3>
<p><strong>7.)</strong> <a href="http://users.skynet.be/mgueury/mozilla/">HTML Validator</a> is a Firefox Plugin that provides an instant status of a page's w3c validation as you browse. It also replaces Firefox's built-in source view, with an intuitive and significantly improved interface. This is one of the best tools out for quickly finding problems with a site's (x)html structure.</p>
<p><img src="http://www.saynotoflash.com/wp-content/uploads/2009/08/google-html.png" alt="google-html" title="google-html" width="510" height="551" class="aligncenter size-full wp-image-324" /></p>
<p><strong>8.)</strong> <a href="http://getfirebug.com/">Firebug</a> is an outstanding debugging program that provides a ton of information about structure, scripts, and problems. Firebug is an amazing tool, but can be quite complex, which is why I also use the HTML Validator plugin.</p>
<p><img src="http://www.saynotoflash.com/wp-content/uploads/2009/08/firebug.png" alt="firebug" title="firebug" width="538" height="54" class="aligncenter size-full wp-image-325" /></p>
<h3>Version Control:</h3>
<p><strong>9.)</strong> <a href="http://www.git-scm.org/">Git</a> is a very fast version control system, that supports quick branching, merging, and development capabilities. There are a number of public GIT hosting sites such as <a href="http://github.com/">github</a> that allow developers to publish and collaborate on their projects.</p>
<blockquote><p>Git gives each developer a local copy of the entire development history, and changes are copied from one such repository to another. These changes are imported as additional development branches, and can be merged in the same way as a locally developed branch.</p></blockquote>
<p><strong>10.)</strong> <a href="http://subversion.tigris.org/">Subversion</a> or SVN is another version control system, ironically despised by the creator of GIT, but is very commonly used and should be in any programmers repertoire. It is currently one of the most popular version control methods, and works with just about any platform.</p>
<p><a href="http://www.dzone.com/links/git_vs_svn_comparsion.html">Quick comparison of GIT vs. SVN</a>.</p>
<p><strong>11.)</strong> <a href="http://winmerge.org/">WinMerge</a> is a fast file comparison program for Windows. It allows the user to quickly compare 2 files, and merge or edit as needed. This is by no means a version control method, but can quickly help determine differences between 2 documents.</p>
<p><img src="http://www.saynotoflash.com/wp-content/uploads/2009/08/win-merge.png" alt="win-merge" title="win-merge" width="550" height="433" class="aligncenter size-full wp-image-323" /></p>
<h3>Graphics:</h3>
<p><strong>12.)</strong> <a href="http://www.colorzilla.com/">ColorZilla</a> is a very fast color picker plugin for Firefox. When you need to get a color from a website, ColorZilla is probably the quickest way to do it. Not only will it show the HEX color code, but it shows the RGB values, and exactly what element is using the color. If you ever take on an existing website for further development it can be invaluable in breaking down somebody's poorly designed css stylesheets.</p>
<p><img src="http://www.saynotoflash.com/wp-content/uploads/2009/08/color-zilla.png" alt="color-zilla" title="color-zilla" width="500" height="31" class="aligncenter size-full wp-image-310" /></p>
<p><strong>13.)</strong> <a href="http://colorschemedesigner.com/">Color Scheme Designer</a> is a no BS way to create compatible, attractive color schemes for websites, and user interfaces. There are dozens of color scheme generators out there, but this one does what is needed efficiently, for free, and without any extra fluff. Several pre-defined color patters are a click away, and you can see quick examples of a web page using the color schema that you've generated.</p>
<p><img src="http://www.saynotoflash.com/wp-content/uploads/2009/08/color-schema-designer.png" alt="color-schema-designer" title="color-schema-designer" width="500" height="309" class="aligncenter size-full wp-image-307" /></p>
<h3>Communication:</h3>
<p><strong>14.)</strong> <img src="http://www.saynotoflash.com/wp-content/uploads/2009/08/xlite1.png" alt="xlite" title="xlite" width="200" height="288" class="alignleft size-full wp-image-348" /><a href="http://www.counterpath.com/x-lite.html">X-Lite</a> is a free VOIP Softphone application. It offers all the features that a very advanced phone would have, including video. </p>
<p>In a world where many people have forgotten what a phone is, this is the perfect compromise. You can get a Plantronics headset and USB adapter, a low cost VOIP service, and have unlimited calling anywhere in the US, and possibly the world, as long as you have an internet connection. Don't ignore the good old fashion telephone. Businesses still use these things...</p>
<p><strong>15.)</strong> <a href="http://www.ceruleanstudios.com/">Trillian</a> is a great way to combine all of your IM clients into a single, light-weight app. This program can free up a considerable amount of system resources compared to running multiple IM clients at the same time. It also lets you access all of your IM contacts through a single interface.</p>
<h3>Miscellaneous:</h3>
<p><strong>16.)</strong> <a href="http://www.screengrab.org/">ScreenGrab</a> is a screen capturing program that's slightly better than the <strong>"Prnt Scrn"</strong> button on your keyboard. It can either copy or save a capture to a PNG file. It allows capturing a complete page <em>(including below the fold)</em>, only the visible portion of a screen, by selection, or the entire window. The only drawback is that it only works within Firefox. Any screen captures you see on this or my other blogs are done with ScreenGrab.</p>
<p><strong>17.)</strong> <img src="http://www.saynotoflash.com/wp-content/uploads/2009/08/roboform.png" alt="roboform" title="roboform" width="300" height="215" class="alignright size-full wp-image-302" /><a href="http://www.roboform.com/php/land.php?affid=jeste&#038;frm=frame1">Roboform</a> is a username/password management program, and is the most important browser add-on that I use. I currently have over 2,000 website profiles stored in it <em>(One of many pages shown in the image)</em>, every one with a very secure and unique password like "<strong>fz96Dr%PpaZjaBfk</strong>". </p>
<p>It supports a variety of very advanced features and configurations to help keep your login credentials secure and easy to use.</p>
<p>You can <a href="http://www.roboform.com/dist/affs/AiRoboForm-jeste.exe">download a free trial here</a>.</p>
<p><strong>18.)</strong> <img src="http://www.saynotoflash.com/wp-content/uploads/2009/08/sun-vbox-150x150.png" alt="sun-vbox" title="sun-vbox" width="150" height="150" class="alignleft size-thumbnail wp-image-318" /><a href="http://www.virtualbox.org/">SUN Virtualbox</a> is the best virtual computer deployment package that I've come across. It installs on a number of host operating systems, not just Linux, and supports just about every OS on the market for Virtual Appliances. It is extremely easy to install, is very efficient, and can be customized as required. Virtual hosts can easily be backed up, or cloned and distributed.</p>
<p>If you've been afraid of exploring into Virtualization, I highly recommend looking at Virtualbox. There are so many benefits to this sort of technology, it's something that every developer should be familiar with.</p>
<p><strong>19.)</strong> <a href="http://www.realtimesoft.com/ultramon/">Ultramon </a>is a multi-monitor taskbar program. unfortunately Windows XP does not include for multiple taskbars if you multiple monitors. Ultramon fixes this in a fast, predictable manner, and includes many additional features such as desktop back ground stretching. Ultramon is not free but is far superior to the free multi-taskbar products that are available.</p>
<p><img src="http://www.saynotoflash.com/wp-content/uploads/2009/08/ultramon.png" alt="ultramon" title="ultramon" width="418" height="138" class="aligncenter size-full wp-image-342" /></p>
<p><strong>20.)</strong> <a href="http://sourceforge.net/projects/pdfcreator/">PDF Creator</a> is a PDF printing application. It allows printing any file directly into a PDF. If you don't need the ability to edit existing PDF documents, this is an excellent alternative to purchasing any other PDF software.</p>
<p><img src="http://www.saynotoflash.com/wp-content/uploads/2009/08/pdf-creator.png" alt="pdf-creator" title="pdf-creator" width="439" height="402" class="aligncenter size-full wp-image-339" /></p>
<p>Let me know if you've got your own set of essential tools that help in your development.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saynotoflash.com/archives/20-great-non-php-tools-for-php-developers/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>PHP Magic __get, __set Methods, and Retaining Private and Protected Properties</title>
		<link>http://www.saynotoflash.com/archives/php-magic-__get-__set-methods-and-retaining-private-and-protected-properties/</link>
		<comments>http://www.saynotoflash.com/archives/php-magic-__get-__set-methods-and-retaining-private-and-protected-properties/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 08:00:03 +0000</pubDate>
		<dc:creator>jestep</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.saynotoflash.com/?p=272</guid>
		<description><![CDATA[I have been making an integration with a complex API with hundreds of potential user provided variables, necessitating me use of PHP's Magic __get and __set methods. 
Unfortunately, by using these methods, PHP's restriction on private and protected properties is bypassed, making all properties public. This is completely unacceptable from my coding perspective. 
This class [...]]]></description>
			<content:encoded><![CDATA[<p>I have been making an integration with a complex API with hundreds of potential user provided variables, necessitating me use of PHP's <a href="http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members">Magic __get and __set methods</a>. </p>
<p>Unfortunately, by using these methods, PHP's restriction on private and protected properties is bypassed, making all properties public. This is completely unacceptable from my coding perspective. </p>
<p>This class model overrides the magic __get and __set's ability to alter and access private and protected properties. Public properties are unaffected. This script also allows the class to set and access private and protected properties.</p>
<div class="igBar"><span id="lphp-16"><a href="#" onclick="javascript:showPlainTxt('php-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-16">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> setter_getter_respect </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; private <span style="color:#0000FF;">$current_page</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; private <span style="color:#0000FF;">$private_properties</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> __construct<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$class</span> = <span style="color:#000000; font-weight:bold;">new</span> ReflectionClass<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">__CLASS__</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">current_page</span> = <span style="color:#0000FF;">$class</span>-&gt;<span style="color:#006600;">getFileName</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$class_properties</span> = <a href="http://www.php.net/get_class_vars"><span style="color:#000066;">get_class_vars</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">__CLASS__</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">foreach</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$class_properties</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$class_property_name</span> =&gt; <span style="color:#0000FF;">$property_value</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$prop</span> = <span style="color:#000000; font-weight:bold;">new</span> ReflectionProperty<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">__CLASS__</span>, <span style="color:#0000FF;">$class_property_name</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$prop</span>-&gt;<span style="color:#006600;">isPrivate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> || <span style="color:#0000FF;">$prop</span>-&gt;<span style="color:#006600;">isProtected</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">private_properties</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$prop</span>-&gt;<span style="color:#006600;">getName</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$prop</span>-&gt;<span style="color:#006600;">isPrivate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? <span style="color:#FF0000;">'private'</span> : <span style="color:#FF0000;">'protected'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> __set<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$var</span>, <span style="color:#0000FF;">$val</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$requesting_page</span> = <a href="http://www.php.net/debug_backtrace"><span style="color:#000066;">debug_backtrace</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$requesting_page</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'file'</span><span style="color:#006600; font-weight:bold;">&#93;</span> != <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">current_page</span><span style="color:#006600; font-weight:bold;">&#41;</span> &amp;&amp; <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/array_key_exists"><span style="color:#000066;">array_key_exists</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$var</span>,<span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">private_properties</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/trigger_error"><span style="color:#000066;">trigger_error</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Cannot access "</span>.<span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">private_properties</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$var</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#FF0000;">" property "</span>.<span style="color:#000000; font-weight:bold;">__CLASS__</span>.<span style="color:#FF0000;">"::"</span>.<span style="color:#0000FF;">$var</span>.<span style="color:#FF0000;">" in "</span>.<span style="color:#0000FF;">$requesting_page</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'file'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#FF0000;">"on line "</span>. <span style="color:#0000FF;">$requesting_page</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'line'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<span style="color:#000000; font-weight:bold;">E_USER_ERROR</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#0000FF;">$var</span> = <span style="color:#0000FF;">$val</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> __get<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$var</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$requesting_page</span> = <a href="http://www.php.net/debug_backtrace"><span style="color:#000066;">debug_backtrace</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#0000FF;">$var</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$requesting_page</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'file'</span><span style="color:#006600; font-weight:bold;">&#93;</span> != <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">current_page</span><span style="color:#006600; font-weight:bold;">&#41;</span> &amp;&amp; <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/array_key_exists"><span style="color:#000066;">array_key_exists</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$var</span>,<span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">private_properties</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/trigger_error"><span style="color:#000066;">trigger_error</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Cannot access "</span>.<span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">private_properties</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$var</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#FF0000;">" property "</span>.<span style="color:#000000; font-weight:bold;">__CLASS__</span>.<span style="color:#FF0000;">"::"</span>.<span style="color:#0000FF;">$var</span>.<span style="color:#FF0000;">" in "</span>.<span style="color:#0000FF;">$requesting_page</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'file'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#FF0000;">"on line "</span>. <span style="color:#0000FF;">$requesting_page</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'line'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<span style="color:#000000; font-weight:bold;">E_USER_ERROR</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#0000FF;">$var</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; throw <span style="color:#000000; font-weight:bold;">new</span> Exception<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Required property ["</span> . <span style="color:#0000FF;">$var</span> . <span style="color:#FF0000;">"] has not been set!"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Extended classes will not have access to __get or __set protected properties. I will alter this snippet when I find a suitable method of handling extended classes.</p>
<p>I'm hoping that php alters the way it handles private and protected properties through the magic methods but until then, this is a way to semi-preserve private and protected properties.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saynotoflash.com/archives/php-magic-__get-__set-methods-and-retaining-private-and-protected-properties/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>US States Snippet and SQL Dump</title>
		<link>http://www.saynotoflash.com/archives/us-states-snippet-and-sql-dump/</link>
		<comments>http://www.saynotoflash.com/archives/us-states-snippet-and-sql-dump/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 18:24:28 +0000</pubDate>
		<dc:creator>jestep</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://www.saynotoflash.com/?p=261</guid>
		<description><![CDATA[Here's some US states snippets. Included are php arrays, and a MySQL states dump...
PHP Snippets:
PLAIN TEXT
PHP:




//states and abbreviations snippets


$states = array&#40;'Alaska','Alabama','Arkansas','Arizona','California','Colorado','Connecticut','Delaware','Florida','Georgia','Hawaii','Iowa','Idaho','Illinois','Indiana','Kansas','Kentucky','Louisiana','Massachusetts','Maryland','Maine','Michigan','Minnesota','Missouri','Mississippi','Montana','North Carolina','North Dakota','Nebraska','New Hampshire','New Jersey','New Mexico','Nevada','New York','Ohio','Oklahoma','Oregon','Pennsylvania','Rhode Island','South Carolina','South Dakota','Tennessee','Texas','Utah','Virginia','Vermont','Washington','Wisconsin','West Virginia','Wyoming'&#41;;


&#160;


$abbreviations = array&#40;'AK','AL','AR','AZ','CA','CO','CT','DE','FL','GA','HI','IA','ID','IL','IN','KS','KY','LA','MA','MD','ME','MI','MN','MO','MS','MT','NC','ND','NE','NH','NJ','NM','NV','NY','OH','OK','OR','PA','RI','SC','SD','TN','TX','UT','VA','VT','WA','WI','WV','WY'&#41;;


&#160;


$states_assoc = array&#40;


'AL'=&#62;"Alabama",&#160; 


'AK'=&#62;"Alaska",&#160; 


'AZ'=&#62;"Arizona",&#160; 


'AR'=&#62;"Arkansas",&#160; 


'CA'=&#62;"California",&#160; 


'CO'=&#62;"Colorado",&#160; 


'CT'=&#62;"Connecticut",&#160; 


'DE'=&#62;"Delaware",&#160; 


'DC'=&#62;"District Of Columbia",&#160; 


'FL'=&#62;"Florida",&#160; 


'GA'=&#62;"Georgia",&#160; 


'HI'=&#62;"Hawaii",&#160; 


'ID'=&#62;"Idaho",&#160; 


'IL'=&#62;"Illinois",&#160; 


'IN'=&#62;"Indiana",&#160; 


'IA'=&#62;"Iowa",&#160; 


'KS'=&#62;"Kansas",&#160; 


'KY'=&#62;"Kentucky",&#160; 


'LA'=&#62;"Louisiana",&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Here's some US states snippets. Included are php arrays, and a MySQL states dump...</p>
<p><span id="more-261"></span><strong>PHP Snippets:</strong></p>
<div class="igBar"><span id="lphp-19"><a href="#" onclick="javascript:showPlainTxt('php-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-19">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//states and abbreviations snippets</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$states</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Alaska'</span>,<span style="color:#FF0000;">'Alabama'</span>,<span style="color:#FF0000;">'Arkansas'</span>,<span style="color:#FF0000;">'Arizona'</span>,<span style="color:#FF0000;">'California'</span>,<span style="color:#FF0000;">'Colorado'</span>,<span style="color:#FF0000;">'Connecticut'</span>,<span style="color:#FF0000;">'Delaware'</span>,<span style="color:#FF0000;">'Florida'</span>,<span style="color:#FF0000;">'Georgia'</span>,<span style="color:#FF0000;">'Hawaii'</span>,<span style="color:#FF0000;">'Iowa'</span>,<span style="color:#FF0000;">'Idaho'</span>,<span style="color:#FF0000;">'Illinois'</span>,<span style="color:#FF0000;">'Indiana'</span>,<span style="color:#FF0000;">'Kansas'</span>,<span style="color:#FF0000;">'Kentucky'</span>,<span style="color:#FF0000;">'Louisiana'</span>,<span style="color:#FF0000;">'Massachusetts'</span>,<span style="color:#FF0000;">'Maryland'</span>,<span style="color:#FF0000;">'Maine'</span>,<span style="color:#FF0000;">'Michigan'</span>,<span style="color:#FF0000;">'Minnesota'</span>,<span style="color:#FF0000;">'Missouri'</span>,<span style="color:#FF0000;">'Mississippi'</span>,<span style="color:#FF0000;">'Montana'</span>,<span style="color:#FF0000;">'North Carolina'</span>,<span style="color:#FF0000;">'North Dakota'</span>,<span style="color:#FF0000;">'Nebraska'</span>,<span style="color:#FF0000;">'New Hampshire'</span>,<span style="color:#FF0000;">'New Jersey'</span>,<span style="color:#FF0000;">'New Mexico'</span>,<span style="color:#FF0000;">'Nevada'</span>,<span style="color:#FF0000;">'New York'</span>,<span style="color:#FF0000;">'Ohio'</span>,<span style="color:#FF0000;">'Oklahoma'</span>,<span style="color:#FF0000;">'Oregon'</span>,<span style="color:#FF0000;">'Pennsylvania'</span>,<span style="color:#FF0000;">'Rhode Island'</span>,<span style="color:#FF0000;">'South Carolina'</span>,<span style="color:#FF0000;">'South Dakota'</span>,<span style="color:#FF0000;">'Tennessee'</span>,<span style="color:#FF0000;">'Texas'</span>,<span style="color:#FF0000;">'Utah'</span>,<span style="color:#FF0000;">'Virginia'</span>,<span style="color:#FF0000;">'Vermont'</span>,<span style="color:#FF0000;">'Washington'</span>,<span style="color:#FF0000;">'Wisconsin'</span>,<span style="color:#FF0000;">'West Virginia'</span>,<span style="color:#FF0000;">'Wyoming'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$abbreviations</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'AK'</span>,<span style="color:#FF0000;">'AL'</span>,<span style="color:#FF0000;">'AR'</span>,<span style="color:#FF0000;">'AZ'</span>,<span style="color:#FF0000;">'CA'</span>,<span style="color:#FF0000;">'CO'</span>,<span style="color:#FF0000;">'CT'</span>,<span style="color:#FF0000;">'DE'</span>,<span style="color:#FF0000;">'FL'</span>,<span style="color:#FF0000;">'GA'</span>,<span style="color:#FF0000;">'HI'</span>,<span style="color:#FF0000;">'IA'</span>,<span style="color:#FF0000;">'ID'</span>,<span style="color:#FF0000;">'IL'</span>,<span style="color:#FF0000;">'IN'</span>,<span style="color:#FF0000;">'KS'</span>,<span style="color:#FF0000;">'KY'</span>,<span style="color:#FF0000;">'LA'</span>,<span style="color:#FF0000;">'MA'</span>,<span style="color:#FF0000;">'MD'</span>,<span style="color:#FF0000;">'ME'</span>,<span style="color:#FF0000;">'MI'</span>,<span style="color:#FF0000;">'MN'</span>,<span style="color:#FF0000;">'MO'</span>,<span style="color:#FF0000;">'MS'</span>,<span style="color:#FF0000;">'MT'</span>,<span style="color:#FF0000;">'NC'</span>,<span style="color:#FF0000;">'ND'</span>,<span style="color:#FF0000;">'NE'</span>,<span style="color:#FF0000;">'NH'</span>,<span style="color:#FF0000;">'NJ'</span>,<span style="color:#FF0000;">'NM'</span>,<span style="color:#FF0000;">'NV'</span>,<span style="color:#FF0000;">'NY'</span>,<span style="color:#FF0000;">'OH'</span>,<span style="color:#FF0000;">'OK'</span>,<span style="color:#FF0000;">'OR'</span>,<span style="color:#FF0000;">'PA'</span>,<span style="color:#FF0000;">'RI'</span>,<span style="color:#FF0000;">'SC'</span>,<span style="color:#FF0000;">'SD'</span>,<span style="color:#FF0000;">'TN'</span>,<span style="color:#FF0000;">'TX'</span>,<span style="color:#FF0000;">'UT'</span>,<span style="color:#FF0000;">'VA'</span>,<span style="color:#FF0000;">'VT'</span>,<span style="color:#FF0000;">'WA'</span>,<span style="color:#FF0000;">'WI'</span>,<span style="color:#FF0000;">'WV'</span>,<span style="color:#FF0000;">'WY'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$states_assoc</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'AL'</span>=&gt;<span style="color:#FF0000;">"Alabama"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'AK'</span>=&gt;<span style="color:#FF0000;">"Alaska"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'AZ'</span>=&gt;<span style="color:#FF0000;">"Arizona"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'AR'</span>=&gt;<span style="color:#FF0000;">"Arkansas"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'CA'</span>=&gt;<span style="color:#FF0000;">"California"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'CO'</span>=&gt;<span style="color:#FF0000;">"Colorado"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'CT'</span>=&gt;<span style="color:#FF0000;">"Connecticut"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'DE'</span>=&gt;<span style="color:#FF0000;">"Delaware"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'DC'</span>=&gt;<span style="color:#FF0000;">"District Of Columbia"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'FL'</span>=&gt;<span style="color:#FF0000;">"Florida"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'GA'</span>=&gt;<span style="color:#FF0000;">"Georgia"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'HI'</span>=&gt;<span style="color:#FF0000;">"Hawaii"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'ID'</span>=&gt;<span style="color:#FF0000;">"Idaho"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'IL'</span>=&gt;<span style="color:#FF0000;">"Illinois"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'IN'</span>=&gt;<span style="color:#FF0000;">"Indiana"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'IA'</span>=&gt;<span style="color:#FF0000;">"Iowa"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'KS'</span>=&gt;<span style="color:#FF0000;">"Kansas"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'KY'</span>=&gt;<span style="color:#FF0000;">"Kentucky"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'LA'</span>=&gt;<span style="color:#FF0000;">"Louisiana"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'ME'</span>=&gt;<span style="color:#FF0000;">"Maine"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'MD'</span>=&gt;<span style="color:#FF0000;">"Maryland"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'MA'</span>=&gt;<span style="color:#FF0000;">"Massachusetts"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'MI'</span>=&gt;<span style="color:#FF0000;">"Michigan"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'MN'</span>=&gt;<span style="color:#FF0000;">"Minnesota"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'MS'</span>=&gt;<span style="color:#FF0000;">"Mississippi"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'MO'</span>=&gt;<span style="color:#FF0000;">"Missouri"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'MT'</span>=&gt;<span style="color:#FF0000;">"Montana"</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'NE'</span>=&gt;<span style="color:#FF0000;">"Nebraska"</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'NV'</span>=&gt;<span style="color:#FF0000;">"Nevada"</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'NH'</span>=&gt;<span style="color:#FF0000;">"New Hampshire"</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'NJ'</span>=&gt;<span style="color:#FF0000;">"New Jersey"</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'NM'</span>=&gt;<span style="color:#FF0000;">"New Mexico"</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'NY'</span>=&gt;<span style="color:#FF0000;">"New York"</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'NC'</span>=&gt;<span style="color:#FF0000;">"North Carolina"</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'ND'</span>=&gt;<span style="color:#FF0000;">"North Dakota"</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'OH'</span>=&gt;<span style="color:#FF0000;">"Ohio"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'OK'</span>=&gt;<span style="color:#FF0000;">"Oklahoma"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'OR'</span>=&gt;<span style="color:#FF0000;">"Oregon"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'PA'</span>=&gt;<span style="color:#FF0000;">"Pennsylvania"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'RI'</span>=&gt;<span style="color:#FF0000;">"Rhode Island"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'SC'</span>=&gt;<span style="color:#FF0000;">"South Carolina"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'SD'</span>=&gt;<span style="color:#FF0000;">"South Dakota"</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'TN'</span>=&gt;<span style="color:#FF0000;">"Tennessee"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'TX'</span>=&gt;<span style="color:#FF0000;">"Texas"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'UT'</span>=&gt;<span style="color:#FF0000;">"Utah"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'VT'</span>=&gt;<span style="color:#FF0000;">"Vermont"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'VA'</span>=&gt;<span style="color:#FF0000;">"Virginia"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'WA'</span>=&gt;<span style="color:#FF0000;">"Washington"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'WV'</span>=&gt;<span style="color:#FF0000;">"West Virginia"</span>,&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'WI'</span>=&gt;<span style="color:#FF0000;">"Wisconsin"</span>,&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF0000;">'WY'</span>=&gt;<span style="color:#FF0000;">"Wyoming"</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>MySQL Snippets:</strong></p>
<div class="igBar"><span id="lsql-20"><a href="#" onclick="javascript:showPlainTxt('sql-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-20">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">-- ----------------------------</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">-- Table structure for states</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">-- ----------------------------</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`states`</span> <span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #ff0000;">`state_id`</span> tinyint<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #ff0000;">`state_name`</span> varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">22</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #ff0000;">`state_abbreviation`</span> char<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span>&nbsp; <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">`state_id`</span><span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #993333; font-weight: bold;">UNIQUE</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #ff0000;">`state_abbreviation`</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">`state_abbreviation`</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span> ENGINE=InnoDB <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span>=<span style="color: #cc66cc;color:#800000;">52</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET=utf8;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">-- ----------------------------</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">-- Records </span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">-- ----------------------------</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'1'</span>, <span style="color: #ff0000;">'Alabama'</span>, <span style="color: #ff0000;">'AL'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'2'</span>, <span style="color: #ff0000;">'Alaska'</span>, <span style="color: #ff0000;">'AK'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'3'</span>, <span style="color: #ff0000;">'Arizona'</span>, <span style="color: #ff0000;">'AZ'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'4'</span>, <span style="color: #ff0000;">'Arkansas'</span>, <span style="color: #ff0000;">'AR'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'5'</span>, <span style="color: #ff0000;">'California'</span>, <span style="color: #ff0000;">'CA'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'6'</span>, <span style="color: #ff0000;">'Colorado'</span>, <span style="color: #ff0000;">'CO'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'7'</span>, <span style="color: #ff0000;">'Connecticut'</span>, <span style="color: #ff0000;">'CT'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'8'</span>, <span style="color: #ff0000;">'Delaware'</span>, <span style="color: #ff0000;">'DE'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'9'</span>, <span style="color: #ff0000;">'District of Columbia'</span>, <span style="color: #ff0000;">'DC'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'10'</span>, <span style="color: #ff0000;">'Florida'</span>, <span style="color: #ff0000;">'FL'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'11'</span>, <span style="color: #ff0000;">'Georgia'</span>, <span style="color: #ff0000;">'GA'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'12'</span>, <span style="color: #ff0000;">'Hawaii'</span>, <span style="color: #ff0000;">'HI'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'13'</span>, <span style="color: #ff0000;">'Idaho'</span>, <span style="color: #ff0000;">'ID'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'14'</span>, <span style="color: #ff0000;">'Illinois'</span>, <span style="color: #ff0000;">'IL'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'15'</span>, <span style="color: #ff0000;">'Indiana'</span>, <span style="color: #ff0000;">'IN'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'16'</span>, <span style="color: #ff0000;">'Iowa'</span>, <span style="color: #ff0000;">'IA'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'17'</span>, <span style="color: #ff0000;">'Kansas'</span>, <span style="color: #ff0000;">'KS'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'18'</span>, <span style="color: #ff0000;">'Kentucky'</span>, <span style="color: #ff0000;">'KY'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'19'</span>, <span style="color: #ff0000;">'Louisiana'</span>, <span style="color: #ff0000;">'LA'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'20'</span>, <span style="color: #ff0000;">'Maine'</span>, <span style="color: #ff0000;">'ME'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'21'</span>, <span style="color: #ff0000;">'Maryland'</span>, <span style="color: #ff0000;">'MD'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'22'</span>, <span style="color: #ff0000;">'Massachusetts'</span>, <span style="color: #ff0000;">'MA'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'23'</span>, <span style="color: #ff0000;">'Michigan'</span>, <span style="color: #ff0000;">'MI'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'24'</span>, <span style="color: #ff0000;">'Minnesota'</span>, <span style="color: #ff0000;">'MN'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'25'</span>, <span style="color: #ff0000;">'Mississippi'</span>, <span style="color: #ff0000;">'MS'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'26'</span>, <span style="color: #ff0000;">'Missouri'</span>, <span style="color: #ff0000;">'MO'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'27'</span>, <span style="color: #ff0000;">'Montana'</span>, <span style="color: #ff0000;">'MT'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'28'</span>, <span style="color: #ff0000;">'Nebraska'</span>, <span style="color: #ff0000;">'NE'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'29'</span>, <span style="color: #ff0000;">'Nevada'</span>, <span style="color: #ff0000;">'NV'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'30'</span>, <span style="color: #ff0000;">'New Hampshire'</span>, <span style="color: #ff0000;">'NH'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'31'</span>, <span style="color: #ff0000;">'New Jersey'</span>, <span style="color: #ff0000;">'NJ'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'32'</span>, <span style="color: #ff0000;">'New Mexico'</span>, <span style="color: #ff0000;">'NM'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'33'</span>, <span style="color: #ff0000;">'New York'</span>, <span style="color: #ff0000;">'NY'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'34'</span>, <span style="color: #ff0000;">'North Carolina'</span>, <span style="color: #ff0000;">'NC'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'35'</span>, <span style="color: #ff0000;">'North Dakota'</span>, <span style="color: #ff0000;">'ND'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'36'</span>, <span style="color: #ff0000;">'Ohio'</span>, <span style="color: #ff0000;">'OH'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'37'</span>, <span style="color: #ff0000;">'Oklahoma'</span>, <span style="color: #ff0000;">'OK'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'38'</span>, <span style="color: #ff0000;">'Oregon'</span>, <span style="color: #ff0000;">'OR'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'39'</span>, <span style="color: #ff0000;">'Pennsylvania'</span>, <span style="color: #ff0000;">'PA'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'40'</span>, <span style="color: #ff0000;">'Rhode Island'</span>, <span style="color: #ff0000;">'RI'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'41'</span>, <span style="color: #ff0000;">'South Carolina'</span>, <span style="color: #ff0000;">'SC'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'42'</span>, <span style="color: #ff0000;">'South Dakota'</span>, <span style="color: #ff0000;">'SD'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'43'</span>, <span style="color: #ff0000;">'Tennessee'</span>, <span style="color: #ff0000;">'TN'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'44'</span>, <span style="color: #ff0000;">'Texas'</span>, <span style="color: #ff0000;">'TX'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'45'</span>, <span style="color: #ff0000;">'Utah'</span>, <span style="color: #ff0000;">'UT'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'46'</span>, <span style="color: #ff0000;">'Vermont'</span>, <span style="color: #ff0000;">'VT'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'47'</span>, <span style="color: #ff0000;">'Virginia'</span>, <span style="color: #ff0000;">'VA'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'48'</span>, <span style="color: #ff0000;">'Washington'</span>, <span style="color: #ff0000;">'WA'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'49'</span>, <span style="color: #ff0000;">'West Virginia'</span>, <span style="color: #ff0000;">'WV'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'50'</span>, <span style="color: #ff0000;">'Wisconsin'</span>, <span style="color: #ff0000;">'WI'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`states`</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'51'</span>, <span style="color: #ff0000;">'Wyoming'</span>, <span style="color: #ff0000;">'WY'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saynotoflash.com/archives/us-states-snippet-and-sql-dump/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Script benchmark / bottleneck debugging snippet</title>
		<link>http://www.saynotoflash.com/archives/php-script-benchmark-bottleneck-debugging-snippet/</link>
		<comments>http://www.saynotoflash.com/archives/php-script-benchmark-bottleneck-debugging-snippet/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 13:00:59 +0000</pubDate>
		<dc:creator>jestep</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://www.saynotoflash.com/?p=244</guid>
		<description><![CDATA[Here's a really simple function that I use for finding bottlenecks in php scripts. You can add any number of steps to the the script using the microtime() function, and this function shows the execution time of each step.
PLAIN TEXT
PHP:




/**


 * Benchmark a php script


 *


 * @param array $time_sample


 * @return string HTML


 */


function [...]]]></description>
			<content:encoded><![CDATA[<p>Here's a really simple function that I use for finding bottlenecks in php scripts. You can add any number of steps to the the script using the microtime() function, and this function shows the execution time of each step.</p>
<div class="igBar"><span id="lphp-23"><a href="#" onclick="javascript:showPlainTxt('php-23'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-23">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * Benchmark a php script</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> *</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * @param array $time_sample</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * @return string HTML</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> quick_benchmark<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$time_sample</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$steps</span> = <a href="http://www.php.net/count"><span style="color:#000066;">count</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$time_sample</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$output</span> = <span style="color:#FF0000;">''</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">for</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$i</span>=<span style="color:#CC66CC;color:#800000;">0</span>;<span style="color:#0000FF;">$i</span>&lt;<span style="color:#0000FF;">$steps</span>;<span style="color:#0000FF;">$i</span>++<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$i</span>&lt;<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$steps</span>-<span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$output</span> .= <span style="color:#FF0000;">'&lt;p&gt;Time '</span>. <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$i</span>+<span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> .<span style="color:#FF0000;">': '</span>. <a href="http://www.php.net/number_format"><span style="color:#000066;">number_format</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$time_sample</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$i</span>+<span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span> - <span style="color:#0000FF;">$time_sample</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$i</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>,<span style="color:#CC66CC;color:#800000;">6</span>,<span style="color:#FF0000;">'.'</span>,<span style="color:#FF0000;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span> .<span style="color:#FF0000;">' seconds.&lt;/p&gt;'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$output</span> .= <span style="color:#FF0000;">'&lt;p&gt;Total time: '</span>. <a href="http://www.php.net/number_format"><span style="color:#000066;">number_format</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$time_sample</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$steps</span>-<span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span> - <span style="color:#0000FF;">$time_sample</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>,<span style="color:#CC66CC;color:#800000;">6</span>,<span style="color:#FF0000;">'.'</span>,<span style="color:#FF0000;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span> .<span style="color:#FF0000;">' seconds.&lt;/p&gt;'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$output</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This is a simple example using sleep() to demonstrate the output.</p>
<div class="igBar"><span id="lphp-24"><a href="#" onclick="javascript:showPlainTxt('php-24'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-24">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$time_sample</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <a href="http://www.php.net/microtime"><span style="color:#000066;">microtime</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">//start</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/sleep"><span style="color:#000066;">sleep</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$time_sample</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <a href="http://www.php.net/microtime"><span style="color:#000066;">microtime</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">//time 1</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/sleep"><span style="color:#000066;">sleep</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$time_sample</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <a href="http://www.php.net/microtime"><span style="color:#000066;">microtime</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">//time 2</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/sleep"><span style="color:#000066;">sleep</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$time_sample</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <a href="http://www.php.net/microtime"><span style="color:#000066;">microtime</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">//time 3</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/sleep"><span style="color:#000066;">sleep</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$time_sample</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <a href="http://www.php.net/microtime"><span style="color:#000066;">microtime</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#FF9933; font-style:italic;">//time 4</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> quick_benchmark<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$time_sample</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>The script outputs:</strong></p>
<p>Time 1: 1.001833 seconds.<br />
Time 2: 2.001427 seconds.<br />
Time 3: 3.001124 seconds.<br />
Time 4: 1.001720 seconds.<br />
Total time: 7.006104 seconds.</p>
<p>It's a good idea to comment each time you record a microtime so that you know which section of script took that amount of time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saynotoflash.com/archives/php-script-benchmark-bottleneck-debugging-snippet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Random string generator snippet</title>
		<link>http://www.saynotoflash.com/archives/php-random-string-generator-snippet/</link>
		<comments>http://www.saynotoflash.com/archives/php-random-string-generator-snippet/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 15:42:11 +0000</pubDate>
		<dc:creator>jestep</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://www.saynotoflash.com/?p=231</guid>
		<description><![CDATA[This is a little function that I use all the time to generate random strings. There are 3 options for random strings with this: Alpha, Alpha-numeric, and Alpha-numeric with symbols. This is important because sometimes it's a good idea not to allow special characters in a php string. However, the special characters are great if [...]]]></description>
			<content:encoded><![CDATA[<p>This is a little function that I use all the time to generate random strings. There are 3 options for random strings with this: Alpha, Alpha-numeric, and Alpha-numeric with symbols. This is important because sometimes it's a good idea not to allow special characters in a php string. However, the special characters are great if you need to create a key or initialization vector for <a href="http://www.saynotoflash.com/archives/php-aes-encryption/">2 way encryption</a>.</p>
<p>This can be used to generate random passwords or keys or just about anything else that needs a random string. You can also throw this directly into a class and use it as a static method.</p>
<div class="igBar"><span id="lphp-29"><a href="#" onclick="javascript:showPlainTxt('php-29'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-29">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * Generate a random string</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> *</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * @param int $length</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * @param int $mode 1 = Alpha, 2 = Alpha-numeric, 3 = Alpha-numeric with symbols</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * @param boolian $char_set Set true for Upper and Lower case letters</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * @return string </span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> random_string<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$length</span>=<span style="color:#CC66CC;color:#800000;">16</span>,<span style="color:#0000FF;">$mode</span>=<span style="color:#CC66CC;color:#800000;">1</span>,<span style="color:#0000FF;">$char_set</span>=<span style="color:#000000; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$string</span> = <span style="color:#FF0000;">''</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$possible</span> = <span style="color:#FF0000;">'ABCDEFGHIJKLMNOPQRSTUVWXYZ'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$char_set</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$possible</span> .= <a href="http://www.php.net/strtolower"><span style="color:#000066;">strtolower</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$possible</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">switch</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$mode</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">case</span> <span style="color:#CC66CC;color:#800000;">3</span>:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$possible</span> .= <span style="color:#FF0000;">'`~!@#$%^&amp;*()_-+=|}]{[&quot;:;&lt;,&gt;.?/'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">case</span> <span style="color:#CC66CC;color:#800000;">2</span>:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$possible</span> .= <span style="color:#FF0000;">'0123456789'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">break</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">for</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$i</span>=<span style="color:#CC66CC;color:#800000;">1</span>;<span style="color:#0000FF;">$i</span>&lt;<span style="color:#0000FF;">$length</span>;<span style="color:#0000FF;">$i</span>++<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$char</span> = <a href="http://www.php.net/substr"><span style="color:#000066;">substr</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$possible</span>, <a href="http://www.php.net/mt_rand"><span style="color:#000066;">mt_rand</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">0</span>, <a href="http://www.php.net/strlen"><span style="color:#000066;">strlen</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$possible</span><span style="color:#006600; font-weight:bold;">&#41;</span>-<span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$string</span> .= <span style="color:#0000FF;">$char</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$string</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>Examples:</strong></p>
<div class="igBar"><span id="lphp-30"><a href="#" onclick="javascript:showPlainTxt('php-30'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-30">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> random_string<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">32</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//WQTISVJVMWSEFXEIQISJPCBENFEHQAN </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lphp-31"><a href="#" onclick="javascript:showPlainTxt('php-31'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-31">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> random_string<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">16</span>,<span style="color:#CC66CC;color:#800000;">2</span>,<span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//cZhVGHJb0PqJIk3 </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lphp-32"><a href="#" onclick="javascript:showPlainTxt('php-32'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-32">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> random_string<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">16</span>,<span style="color:#CC66CC;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//=,:UT__GN[ST&gt;GH </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saynotoflash.com/archives/php-random-string-generator-snippet/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>25 Point Basic MySQL Setup/Optimization Checklist</title>
		<link>http://www.saynotoflash.com/archives/25-point-basic-mysql-setupoptimization-checklist/</link>
		<comments>http://www.saynotoflash.com/archives/25-point-basic-mysql-setupoptimization-checklist/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 21:29:43 +0000</pubDate>
		<dc:creator>jestep</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.saynotoflash.com/?p=170</guid>
		<description><![CDATA[Daily I run into new web programmers that are using PHP and MySQL to create their blogs and websites. I created this checklist as a guide for new and experienced to make sure they are covering the basics of a MySQL server setup. 
This guide is by no means all inclusive, but should help to [...]]]></description>
			<content:encoded><![CDATA[<p>Daily I run into new web programmers that are using PHP and MySQL to create their blogs and websites. I created this checklist as a guide for new and experienced to make sure they are covering the basics of a MySQL server setup. </p>
<p>This guide is by no means all inclusive, but should help to cover some of the major gaps in knowledge and commonly overlooked fundamentals that I run into on a daily basis.</p>
<p>The checklist is separated into 5 equal sections: Server Setup, Schema Design, Table Design, Index Optimization, Query Optimization, and a 6th Bonus Tips section. </p>
<p><span id="more-170"></span>You can also <a href="http://www.saynotoflash.com/downloads/25-point-mysql.pdf">download a simplified summary</a> on PDF form.</p>
<h3>Section 1 - Server Setup</h3>
<ol class="l_spacing">
<li><strong>Root User</strong><br />
For security reasons, the root MYSQL user must be setup with a secure password, and should only have access from localhost. It is a bad idea to allow outside access to the root account. Create additional users if you need to access the database remotely!</li>
<li><strong>Backup and Restore</strong><br />
Before allowing a database to be used in a production environment, there should be a usable backup and restore process. I use the phrase "in case the database server is completely destroyed" because the backup location and method needs to be completely independent from the database server. <em><strong>Note:</strong> Even a weekly database backup is better than no backup at all.</em></li>
<li><strong>Benchmarking</strong><br />
There's no easy way to determine bottlenecks and trouble unless a method to benchmark performance is in place. The slow query log should always be enabled, and it's a good idea to install a <a href="http://dev.mysql.com/doc/refman/5.0/en/mysql-benchmarks.html">benchmarking program</a>. <a href="http://webyog.com/en/">Monyog </a>is an external program that provides a number of real-time reports useful for monitoring and performance tuning.</li>
<li><strong>DNS</strong><br />
If you do not allow outside access, or you can access your server from known IP addresses, <a href="http://dev.mysql.com/doc/refman/5.0/en/dns.html">disabling DNS look-ups</a> can speed up server operations. Additionally, if the MySQL server loses it's DNS look-up service, the usability of the entire Database can all but halt.</li>
<li><strong>Privileges</strong><br />
When adding users to a database, only give them the permissions that are absolutely required, and be specific in where they can access from. "GRANT ALL ON EVERYTHING TO USER@ANYWHERE" is a really bad idea. If you do need to give users full permissions for installations or another purpose, it's a good practice to change them back to the minimum once complete.</li>
</ol>
<h3>Section 2 - Schema Design</h3>
<ol class="l_spacing" start="6">
<li><strong>Naming</strong><br />
A standardized naming scheme should always be used. The best practice is to use lowercase letters with an underscore connecting names, such as <strong>`my_personal_database`</strong>. Tables, and individual column names should carry the same naming convention. Use descriptive names for every column including id columns. `id` is not descriptive whereas `contact_id` is.
</li>
<li><strong>Collation</strong><br />
Use the same collation for all parts of the database, and avoid using UTF-8 or multi-byte formats unless you specifically need them. Keeping the same format on all tables and columns can help prevent data corruption and conversion problems. UTF-8 requires significantly more disk space and overhead which can reduce performance. If you need UTF-8, use it , but don't make your entire database UTF-8 because you're lazy.</li>
<li><strong>Foreign Keys</strong><br />
Always use foreign keys to ensure that bad / incomplete data stays out of the database. Nothing replaces good application level programming, but foreign keys are the best way to prevent putting bad data into your database in the first place. You will need InnoDB to use foreign keys, but the benefit is worth it. </li>
<li><strong>Logically Segmented Data in Tables</strong><br />
Tables should be segmented logically by the data they contain and their association with other tables. In this manner, there may be more total tables, but will help eliminate tables with a huge number of columns which can really hurt performance. Additionally, it will make querying easier as it's unlikely that every column is needed for every query. This also allows for Single-to-many relationships such as storing multiple addresses related to a single entry. <em>Don't be afraid of 20 tables with 20 columns each, <strong>be afraid of 1 table with 400 columns</strong>!</em></li>
<li><strong>Reserved Words</strong><br />
Avoid using <a href="http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html">reserved words</a> for any name in your database schema. Words like date, time, decimal, etc. are often used, and can wreak havoc trying to get queries to work properly, and can cause even more difficulty in debugging. You can technically use these words if they are placed in back-ticks (`date`), but this is a bad practice and should always be avoided.
</li>
</ol>
<h3>Section 3 - Table Design</h3>
<ol class="l_spacing" start="11">
<li><strong>Data types</strong><br />
MySQL has many <a href="http://dev.mysql.com/doc/refman/5.0/en/data-types.html">data types</a>, probably more than any other database. Using the correct data type for the data being stored is one of the most important aspects in design. Failing at this step can break a database's speed and the usability of an application. </p>
<p><a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">Whole Numbers</a> - BIGINT, INT, MEDIUMINT, SMALLINT, TINYINT<br />
<a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html">Decimals</a> - DECIMAL, FLOAT, DOUBLE, REAL<br />
<a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-types.html">Dates</a> - TIMESTAMP*, DATETIME, DATE, TIME, YEAR<br />
<a href="http://dev.mysql.com/doc/refman/5.0/en/string-types.html">Strings</a> - CHAR, VARCHAR, BINARY, VARBINARY, BLOB, TEXT, ENUM, SET</p>
<p>Additionally, using the correct data type allows for the use of MySQL's built-in functions which can sort, do math, comparisons, date conversions, etc. For example, I often see dates stored in VARCHAR columns, which completely prevents MySQL from sorting, or using any date related function.</li>
<li><strong>Large Numerical Keys</strong><br />
It's common for new programmers to use a BIGINT(20) when they need a key column. While admirable, this is a waste of disk space. An UNSIGNED INT(10) has over 4 billion possible numbers, which is more than most will ever use. Even so, by that time, you will want to look into partitioning, and will have a variety of other problems on your hand. Don't use BIGINT's unless you need to store very-very large numbers.
</li>
<li><strong>Smallest Length</strong><br />
Using the smallest length data length is important. Every byte of savings adds up when a database's size and usage goes up. Lazy programming by using VARCHAR(255) or DECIMAL(20,2) creates unnecessary overhead and causes problems down the road. Give yourself one extra byte of space if needed, but 100 is a overkill.
</li>
<li><strong>Avoid TEXT and BLOB Columns</strong><br />
TEXT and BLOB type columns can eat up a server's resources when being selected. While these are most certainly needed to store larger amounts of data, they should only be used for that purpose. VARCHAR can hold up to 255 bytes and should always be used before TEXT whenever possible.
</li>
<li><strong>Non‐Relational Storage</strong><br />
A huge design mistake is storing data in a non-relational format. It's common to see data stored in a CSV format like (value1,value2,value3) in a single column. This effectively bypasses MySQL's ability to use the data. It's best to use multiple tables for single-to-many relationships, as this allows for MySQL to handle the data in an elegant manner. There are some situations where storing csv-like data would make sense, but for all intensive purposes, avoid storing data like this.
</li>
</ol>
<h3>Section 4 - Index Optimization</h3>
<ol class="l_spacing" start="16">
<li><strong>Use proper indexes</strong><br />
MySQL supports several types of indexes (PRIMARY, UNIQUE, NORMAL, PARTIAL, and FULLTEXT). It is important to use the correct type of index for the job. It is also important to only use indexes when needed, and not to create duplicate indexes. For example a primary key column already has an index, so adding a second UNIQUE INDEX on the primary key is a complete waste of overhead and disk space.
</li>
<li><strong>Multi-Column Indexes</strong><br />
If there is a data set that is constantly queried with more than one column in the WHERE clause, it may be a good idea to create a multi-column index. If you have an index on (`user_id`,`user_category`) the index will work when both are in the where clause or the first column (`user_id`) is in the where clause. However, the index will not be used if only `user_category` is in the where clause.
</li>
<li><strong>Modifying Indexed Fields During a Query</strong><br />
Unless you specify the length of an index, modifying an indexed column will prevent the index from being used.<br />
For example, if there is an index on `credit_card_number` and you perform a query like this:<br />
<code>SELECT `user_id` FROM `my_table` WHERE LEFT(`credit_card_number`,4) = '5666';</code><br />
The index will not be used. If this was a common scenario, you could create a partial index of (`credit_card_number`,4), and the above query would use the index.
</li>
<li><strong>Indexes With a High Cardinality</strong><br />
Indexes work best when there are many unique values in relation to the total number of rows. This allows the database engine to quickly reduce the number of possible rows in the result set. Indexes on columns with only a few unique values are inefficient and will end up being a waste of overhead.</li>
<li><strong>Unique and NULL Column Indexes</strong><br />
Allowing NULLS in index columns adds an additional byte of storage per row to the index. This again equates to a waste of space and overhead and will slow down MySQL's performance. It's better to use no value rather than NULL.</li>
</ol>
<h3>Section 5 - Query Optimization</h3>
<ol class="l_spacing" start="21">
<li><strong>Specific Column Names</strong><br />
Always use specific column names instead of * when querying a table. <a href="http://www.parseerror.com/sql/select*isevil.html">SELECT * is lazy programming</a>. While it is completely valid syntax, you won't know the columns that will be returned. If you don't know what you're going to get with a query, there's no reason to use it.. right? Write out any column names that you need data from. This way your code is intuitive, you won't have problems trying to use data from a column that doesn't exist, and the next person using your script wont hate you.
</li>
<li><strong>MySQL's Built-in Functions</strong><br />
MySQL has a variety of very advanced, and very fast, <a href="http://dev.mysql.com/doc/refman/5.0/en/functions.html">built-in functions</a>. They probably are much more efficient than php or most other application level scripts. These functions can greatly increase your application's speed, and reduce its complexity. MySQL has everything from mathematical operations, date comparisons, even spacial functions for calculation geographic equations. Learn to use them.
</li>
<li><strong>Selecting TEXT and BLOB Columns</strong><br />
When a TEXT or BLOB column is select in a query, MySQL will create a temporary internal table. If large result sets are selected with TEXT or BLOB columns, this can create a major load on the database, and unnecessary overhead. This relates back to SELECT *, don't select a TEXT or BLOB type column unless you actually need to use the data.</li>
<li><strong>Use Transactions</strong><br />
Transactions are another great way of preventing incomplete or corrupted data while inserting or altering data. When using a transaction, you can insert or alter any number of rows of data. If there is an error, all of the queries in the transaction will be aborted. Think of inserting 50,000 rows into a report table, and having 10 arbitrary rows not insert correctly. That entire set of data is now corrupt, and a transaction would have prevented that.
</li>
<li><strong>SQL_NO_CACHE</strong><br />
SQL_NO_CACHE is a great way to prevent MySQL from caching a query's result. This is important for results with a rapidly changing data, or very large result sets. Both of these situations can eat up server resources without any gain to the application or end-user.
</li>
</ol>
<h3>Bonus</h3>
<ol class="l_spacing">
<li><strong>TIMESTAMP vs. DATETIME</strong><br />
TIMESTAMP and DATETIME store dates in the exact same format (YYYY-MM-DD HH:MM:SS) but TIMESTAMP uses less space to do so. The only limitation is that TIMESTAMP cannot be used for dates older than Jan 1st, 1970.</li>
<li><strong>SIGNED INT</strong><br />
Unless you need to store negative numbers, only use UNSIGNED INT and other numerical data type fields. There's no reason to allow for negative numbers if they will never be used.</li>
<li><strong>Collation: _ci vs. _cs</strong><br />
The _ci in a collation stands for "case insensitive". If you care about case sensitivity use a collation that ends in _cs. The can be very important for searching and other operations where John &#8800; john!</li>
<li><strong>InnoDB vs. MyISAM</strong><br />
If you're using MyISAM as a storage engine only because it was the default, you may be making a mistake. InnoDB is superior in several areas <em>(Reliability, Backups, Foreign Keys, and <a href="http://www.mysqlperformanceblog.com/2007/01/08/innodb-vs-myisam-vs-falcon-benchmarks-part-1">Performance in many situations</a>)</em> and while maybe not always the best option <em>(Full Text Indexing)</em>, you should know why you're using the engine you're using. You can also mix the 2, but this can make performance tuning especially difficult.</li>
<li><strong>Consult a Professional</strong><br />
When you get a project and the database design, usage or other factor is just over your head, it's a good idea to consult a professional. It may cost a fair sum, but the cost down the road could be substantial. Planning is always cheaper than reacting.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.saynotoflash.com/archives/25-point-basic-mysql-setupoptimization-checklist/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
