<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" version="2.0">

<channel>
	<title>nabeel shahzad</title>
	
	<link>http://nsslive.net</link>
	<description>code 'n chicken</description>
	<lastBuildDate>Sun, 01 Nov 2009 04:10:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/nsslive" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="nsslive" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Host move complete…</title>
		<link>http://nsslive.net/2009/10/31/changed-server-to-linode/</link>
		<comments>http://nsslive.net/2009/10/31/changed-server-to-linode/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 03:56:43 +0000</pubDate>
		<dc:creator>Nabeel</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://nsslive.net/?p=290</guid>
		<description><![CDATA[Completed my long move today over to Linode from Slicehost. A few reasons for the switch &#8211; the main two being the price (I&#8217;m now on a Linode 560, which is 560mb of RAM, vs the 512 at Slicehost for the same price). They also give a 10% discount for pre-paying for a year, or [...]]]></description>
			<content:encoded><![CDATA[<p>Completed my long move today over to Linode from Slicehost. A few reasons for the switch &#8211; the main two being the price (I&#8217;m now on a Linode 560, which is 560mb of RAM, vs the 512 at Slicehost for the same price). They also give a 10% discount for pre-paying for a year, or 15% for two years. But you&#8217;re not stuck in a contract. Sweet deal there. The other reason was that Linode doesn&#8217;t force you to go on x64, so you&#8217;re not wasting memory needlessly to the OS. The box &#8220;feels&#8221; faster, probably because I have a lot more free RAM since I chose to go on 32bit. No swap usage so far (alot of room available), with identical set ups. My slice was constantly using swap. My ping times are also certainly lower. So far so good. I got to also chose the data center, over at The Planet in Dallas. The Linode control panel is also &#8220;meatier&#8221;, compared to the Slicehost manager. Linode gives you 24-hour and 30-day usage graphs, with averages and stats on CPU, network, and disk IO. Really useful information. The only downside is that the image backups at Linode are in &#8220;beta&#8221;, but doesn&#8217;t matter so much to be since I use an outside backup service anyway.</p>
<p>I also did a fresh upgrade to Ubuntu 9.10 &#8220;Karmic Koala&#8221;, which is what I was waiting on to make the switch. Went very smoothly; I stayed with nginx, except this time, instead of using the php-fcgi, I decided to try out the php-fpm route. It was a bit of a hassle, and took the better part of a day, though I got it working in the end. But that&#8217;s because it was my first time doing it. I will have a post on that soon. Basically, I installed the Ubuntu 5.2.10 packages, and then compiled php-fpm against that source, which fixed a few issues I was having with configs not getting picked up when I compiled it against the vanilla PHP source. So far so good, running with APC and memcache going. </p>
<p>I think I will next try to compile PHP 5.3 from source, and add PHP-FPM into it, though I feel like waiting for a package. Perhaps a project for next weekend, but definitely something to try on a virtual machine first. I was reading a few bugs that APC was a bit wonky on 5.3, so I might wait until 5.3.1, and that Suhosin is also a bit sketch. Though, it might be some good motivation to try out XCache. To be honest, I was a bit disappointed that 5.3 wasn&#8217;t included by default in 9.10. I was trying to find out when it might be, but I think it could be a while. At least this time around, I took real detailed notes on what I did, from start to finish. I&#8217;m not so afraid of compiling this time around. For instance, nginx, I compared the layout of the Ubuntu repository copy, and mimicked that with &#8211;prefix and the &#8211;sbin-path configure options. It&#8217;s just convenient having the &#8220;sudo apt-get upgrade&#8221; command. Ubuntu also made it real easy in terms of dependencies. I remember a few years ago trying to compile stuff, and it was always a nightmare. I think that&#8217;s what scared me away from it, but it was pretty painless this time around.</p>
<p>Other updates &#8211; phpVMS, a lot of progress, thanks to everyone for helping test, fixing alot of bugs. Made alot of core changes too, which I&#8217;ll detail in the release post &#8211; hopefully in a few weeks. Same with vaCentral, I&#8217;m trying to get them both out at the same time. But thanks to everyone testing, I&#8217;ve been able to nail a lot of bugs. It&#8217;s looking much better than it did a few weeks ago.</p>
<p>Anyway, I&#8217;m fried. Time for a break. And, Happy Halloween!</p>
]]></content:encoded>
			<wfw:commentRss>http://nsslive.net/2009/10/31/changed-server-to-linode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Function Parameter Hell</title>
		<link>http://nsslive.net/2009/10/09/function-parameter-hell/</link>
		<comments>http://nsslive.net/2009/10/09/function-parameter-hell/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 04:10:03 +0000</pubDate>
		<dc:creator>Nabeel</dc:creator>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://nsslive.net/?p=282</guid>
		<description><![CDATA[Everyone&#8217;s used those functions with an obscene number of parameters. And everyone&#8217;s created those functions too (big time guilty here).
Like this is a function I wrote for vaCentral to process any images you upload for your airline (logo, gallery, etc)

function process_file_upload($file, $slug, $title, $ext='PNG', $full_size=300, $small_size=100)
{
	...
}

Now that&#8217;s just a mess. Taking a hint from Javascript [...]]]></description>
			<content:encoded><![CDATA[<p>Everyone&#8217;s used those functions with an obscene number of parameters. And everyone&#8217;s created those functions too (big time guilty here).<br />
Like this is a function I wrote for vaCentral to process any images you upload for your airline (logo, gallery, etc)</p>
<pre class="brush: php;">
function process_file_upload($file, $slug, $title, $ext='PNG', $full_size=300, $small_size=100)
{
	...
}
</pre>
<p>Now that&#8217;s just a mess. Taking a hint from Javascript and jQuery, we can instead use arrays to pass in parameters, making it sane, and more importantly, readable. So it will look something like this:</p>
<pre class="brush: php;">
$options = array (
	'file'=&gt;$this-&gt;params['form'][$image],
	'slug'=&gt;$folder,
	'title'=&gt;$image,
	'ext'=&gt;$ext,
	'full_size'=&gt;$large_size,
	'small_size'=&gt;$this-&gt;small_size
	);

$this-&gt;process_image_upload($options);
</pre>
<p>Alright, that sounds better. And looks much better, and I can actually understand what&#8217;s going on. But how will we work with this? As you&#8217;ve probably noticed, default parameters are gone. Here&#8217;s the code:</p>
<pre class="brush: php;">
// Setup our options for what we want to pass
$options = array(
	'parameter1'=&gt;'apples',
	'parameter3'=&gt;'grapes',
	);

some_function($options);

function some_function($options)
{
	// Now these are the defaults
	$defaults = array(
		'parameter1'=&gt;'oranges',
		'parameter2'=&gt;'watermelons',
		'parameter3'=&gt;'grapefruit',
		'parameter4'=&gt;''
	);

	/* Now we merge the two arrays, except the $options
		array takes precedence */
	$options = array_merge($defaults, $options);

	/* extract() creates a variable with every key from the array
		so we can use that variable directly, this is optional */
	extract($options);

	// So now we can use the variables directly
	echo $parameter1; // This will echo &quot;apples&quot;
	echo $parameter2; // This will echo &quot;watermelons&quot;

	/* Suppose parameter4 has to be set, so we will trigger an error
		You can use throw as well if it's in a try/catch block */
	if($parameter4 == '')
	{
		trigger_error('Parameter 4 must be set to &quot;this value&quot; or &quot;that value&quot;', E_USER_WARNING);
	}

	/* Or, if you assume that the $defaults set with '' are mandatory to fill out,
		you can use this code */
	foreach($defaults as $name=&gt;$value)
	{
		if($values == '' &amp;&amp; $options[$name] == '' || !isset($options[$name]))
		{
			trigger_error(&quot;{$name} is blank, must have a value&quot;, E_USER_WARNING);
		}
	}
}
</pre>
<p>Now obviously this is a little more involving, but it&#8217;s not too bad, and in my opinion, it&#8217;s well worth the extra effort needed. My tipping point is functions with more than 3 parameters will get array&#8217;d options. This also requires documentation, but I don&#8217;t think that&#8217;s such a bad thing (your sanity will thank you later). You can also peek into the function&#8217;s source code to see the parameters. But this also gives you a bit more control over error messages as well, with the trigger_error, so there&#8217;s no difference from how PHP natively reports it.</p>
<p>Also, another advantage is adding and removing parameters. You don&#8217;t need to reorder or completely destroy things, when in the future you decide to add or remove a parameter, which makes it real handy for API type functions. Debugging and logging can also be easier, since you can dump the entire parameters array in one swoop, without having to output every single variable, one at a time. The only drawback is the lack of restrictions on a blank value, but since there is a way around it, and you&#8217;re forced to check it, IMO that&#8217;s an advantage in the end, especially since my motto is to never trust any data coming into the system, especially in an API.</p>
]]></content:encoded>
			<wfw:commentRss>http://nsslive.net/2009/10/09/function-parameter-hell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A better way for nginx PHP config</title>
		<link>http://nsslive.net/2009/10/06/a-better-way-for-nginx-php-config/</link>
		<comments>http://nsslive.net/2009/10/06/a-better-way-for-nginx-php-config/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 22:23:01 +0000</pubDate>
		<dc:creator>Nabeel</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://nsslive.net/?p=277</guid>
		<description><![CDATA[Doing some reconfiguration on my webserver (nginx) to make it easier to administer. My first goal was to get rid of this nastiness:

server {
  ...

  location ~ \.php$ {
        include /etc/nginx/conf/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
      [...]]]></description>
			<content:encoded><![CDATA[<p>Doing some reconfiguration on my webserver (nginx) to make it easier to administer. My first goal was to get rid of this nastiness:</p>
<pre class="brush: bash;">
server {
  ...

  location ~ \.php$ {
        include /etc/nginx/conf/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /var/path/to/$fastcgi_script_name;
  }
}
</pre>
<p>It&#8217;s too verbose to copy/paste into each virtual host file. Instead, you can just combine the file into the /etc/nginx/conf/fastcgi_params file. I renamed it to php_params, and this is what it&#8217;s got:</p>
<pre class="brush: bash;">
location ~ \.php(.*)$ {
  fastcgi_pass  127.0.0.1:9000;
  fastcgi_index index.php;

  fastcgi_param  QUERY_STRING       $query_string;
  fastcgi_param  REQUEST_METHOD     $request_method;
  fastcgi_param  CONTENT_TYPE       $content_type;
  fastcgi_param  CONTENT_LENGTH     $content_length;

  fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
  fastcgi_param  REQUEST_URI        $request_uri;
  fastcgi_param  DOCUMENT_URI       $document_uri;
  fastcgi_param  DOCUMENT_ROOT      $document_root;
  fastcgi_param  SERVER_PROTOCOL    $server_protocol;

  fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;

  fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
  fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

  fastcgi_param  REMOTE_ADDR        $remote_addr;
  fastcgi_param  REMOTE_PORT        $remote_port;
  fastcgi_param  SERVER_ADDR        $server_addr;
  fastcgi_param  SERVER_PORT        $server_port;
  fastcgi_param  SERVER_NAME        $server_name;

  # PHP only, required if PHP was built with --enable-force-cgi-redirect
  fastcgi_param  REDIRECT_STATUS    200;
}
</pre>
<p>Now I don&#8217;t have to change it everywhere. So, instead, now I do:</p>
<pre class="brush: bash;">
server {
  ...
  # Include the PHP Fast-CGI Params
  include /etc/nginx/conf/php_params;
}
</pre>
<p>Bam! 6 lines down to one, and much easier to administer. I like, I like.</p>
]]></content:encoded>
			<wfw:commentRss>http://nsslive.net/2009/10/06/a-better-way-for-nginx-php-config/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Resources</title>
		<link>http://nsslive.net/2009/10/06/php-resources/</link>
		<comments>http://nsslive.net/2009/10/06/php-resources/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 15:04:30 +0000</pubDate>
		<dc:creator>Nabeel</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://nsslive.net/?p=272</guid>
		<description><![CDATA[I put a list together for a friend of some good PHP resources, thought I&#8217;d stick it up here as well:
Of course, the best resource, the official docs:
http://www.php.net
Another great (official) place:
http://talks.php.net/
The talks are by the creators of PHP. Any talks by Rasmus Lerfdorf are excellent, he stresses simplicity over complexity. He&#8217;s also the creator of [...]]]></description>
			<content:encoded><![CDATA[<p>I put a list together for a friend of some good PHP resources, thought I&#8217;d stick it up here as well:</p>
<p>Of course, the best resource, the official docs:<br />
<a href="http://www.php.net">http://www.php.net</a></p>
<p>Another great (official) place:<br />
<a href="http://talks.php.net/">http://talks.php.net/</a></p>
<p>The talks are by the creators of PHP. Any talks by Rasmus Lerfdorf are excellent, he stresses simplicity over complexity. He&#8217;s also the creator of PHP. Derick Rethans is also an excellent presenter, he focuses a lot on security and debugging. Definitely watch the presentations in the &#8220;Security&#8221; section of the talks, but overall, any talk in there has information you can use to your advantage.</p>
<p>Other sites:<br />
<a href="http://www.smashingmagazine.com/2009/03/24/10-useful-php-tips-revisited/">http://www.smashingmagazine.com/2009/03/24/10-useful-php-tips-revisited/</a><br />
<a href="http://php.about.com/od/advancedphp/Advanced_PHP.htm">http://php.about.com/od/advancedphp/Advanced_PHP.htm</a></p>
<p>Sitepoint is where I first started learning HTML and CSS many years ago:<br />
<a href="http://www.sitepoint.com/subcat/php-tutorials">http://www.sitepoint.com/subcat/php-tutorials</a></p>
<p>MVC tutorials (how apps should be coded; obviously there&#8217;s some contention between OO and procedural styles, but you need knowledge of both to be able to make an educated judgment about what a good balance between the two is)<br />
<a href="http://www.phpro.org/tutorials/Model-View-Controller-MVC.html">http://www.phpro.org/tutorials/Model-View-Controller-MVC.html</a><br />
Good to go through to understand MVC completely</p>
<p>CakePHP has a good introduction:<br />
<a href="http://book.cakephp.org/view/10/Understanding-Model-View-Controller">http://book.cakephp.org/view/10/Understanding-Model-View-Controller</a></p>
<p>Which brings me to CakePHP itself. It&#8217;s an excellent MVC framework; after trying out CodeIgniter, Zend, Yii, Kohana, I&#8217;ve settled on Cake.<br />
<a href="http://cakephp.org/">http://cakephp.org/</a></p>
<p>SQL resources &#8211; the best is the manual. Learning the concepts behind joins is essential and important. A good tutorial:<br />
<a href="http://www.codinghorror.com/blog/archives/000976.html">http://www.codinghorror.com/blog/archives/000976.html</a></p>
<p>Also database design:<br />
<a href="http://www.simple-talk.com/sql/database-administration/ten-common-database-design-mistakes/">http://www.simple-talk.com/sql/database-administration/ten-common-database-design-mistakes/</a><br />
<a href="http://woork.blogspot.com/2008/09/10-useful-articles-about-database.html">http://woork.blogspot.com/2008/09/10-useful-articles-about-database.html</a></p>
<p>Following that up are good ORM, which you may want to use as your database layer. CakePHP has ORM built-in, but sometimes all you need is just a DB layer.<br />
<a href="http://www.doctrine-project.org/">http://www.doctrine-project.org/</a></p>
<p>For conventions, I tend to follow the CakePHP model (since that&#8217;s the framework I use the most):<br />
<a href="http://book.cakephp.org/view/24/Model-and-Database-Conventions">http://book.cakephp.org/view/24/Model-and-Database-Conventions</a><br />
<a href="http://bakery.cakephp.org/articles/view/database-design-and-cakephp">http://bakery.cakephp.org/articles/view/database-design-and-cakephp</a><br />
<a href="http://book.cakephp.org/view/22/CakePHP-Conventions" target="_new">http://book.cakephp.org/view/22/CakePHP-Conventions</a></p>
<p>And then rounding it out, some general knowledge information:<br />
<a href="http://articles.sitepoint.com/category/html" target="_new">http://articles.sitepoint.com/category/html</a><br />
<a href="http://articles.sitepoint.com/category/javascript" target="_new">http://articles.sitepoint.com/category/javascript</a><br />
<a href="http://articles.sitepoint.com/category/cssh" target="_new">http://articles.sitepoint.com/category/cssh</a><br />
<a href="http://www.jquery.com" target="_new">http://www.jquery.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://nsslive.net/2009/10/06/php-resources/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Busy busy</title>
		<link>http://nsslive.net/2009/09/30/busy-busy/</link>
		<comments>http://nsslive.net/2009/09/30/busy-busy/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 18:13:12 +0000</pubDate>
		<dc:creator>Nabeel</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://nsslive.net/?p=268</guid>
		<description><![CDATA[Been a busy few months with work, phpVMS, and vaCentral. I can&#8217;t believe my last post was in July. Time really flies!! But anyway, I&#8217;m hoping to wrap up the last two projects by the end of October. Right now, there&#8217;s 15 airlines participating in testing for vaCentral, and some impressive stats in the last [...]]]></description>
			<content:encoded><![CDATA[<p>Been a busy few months with work, phpVMS, and vaCentral. I can&#8217;t believe my last post was in July. Time really flies!! But anyway, I&#8217;m hoping to wrap up the last two projects by the end of October. Right now, there&#8217;s 15 airlines participating in testing for vaCentral, and some impressive stats in the last two months or so I&#8217;ve been testing:</p>
<ul>
<li>5,055 PIREPs submitted, with an average of 20-30 per day</li>
<li>Over 22,000 flight hours recorded</li>
<li>15 airlines right now, with 705 total pilots</li>
</ul>
<p>If that&#8217;s any indication, I think vaCentral will be a huge success. I&#8217;ve been building it on CakePHP, which has made it real easy for development. Doing some tweaks to ranking and stats, but otherwise, almost there.</p>
<p>In other news, I think I&#8217;ll be transferring everything over to fivedev.net, as a huge portfolio/blog type of thing. Might be better. I&#8217;m still trying to find an alternative to Wordpress, but haven&#8217;t had much luck. I have a couple of PHP articles I&#8217;ve wanted to publish, including one of writing more &#8220;portable&#8221; PHP, with stuff I learned from developing on phpVMS and other projects, but just haven&#8217;t had the time to complete it. Soon, hopefully.</p>
]]></content:encoded>
			<wfw:commentRss>http://nsslive.net/2009/09/30/busy-busy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP Models – multiple columns to the same table</title>
		<link>http://nsslive.net/2009/07/02/cakephp-models-multiple-columns-to-the-same-table/</link>
		<comments>http://nsslive.net/2009/07/02/cakephp-models-multiple-columns-to-the-same-table/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 14:48:24 +0000</pubDate>
		<dc:creator>Nabeel</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://nsslive.net/?p=200</guid>
		<description><![CDATA[This one took me a few to figure out. On VACentral, there are schedules, which have an arrival and departure point. These points are all stored in one table, so one row in schedule refers to multiple entries in the airports table. It looks something like (ok, not something like, but exactly):

Schedules:
id &#124; departure_icao &#124; [...]]]></description>
			<content:encoded><![CDATA[<p>This one took me a few to figure out. On VACentral, there are schedules, which have an arrival and departure point. These points are all stored in one table, so one row in schedule refers to multiple entries in the airports table. It looks something like (ok, not <i>something</i> like, but exactly):</p>
<pre class="brush: plain;">
Schedules:
id | departure_icao | arrival_icao

Airports
id | icao
</pre>
<p>So two ICAO columns in routes map to one same column in airports. The ICAO is a unique 4 character identifier, which is assigned to an airport. It&#8217;s quite simple actually, but took me a while to figure it it. First the Airports model:</p>
<pre class="brush: php;">
class Airport extends AppModel
{
	public $name = 'Airport';
	public $primaryKey = 'id';
	public $actAs = array('Containable');
}
</pre>
<p>And then our Schedules model:</p>
<pre class="brush: php;">
class Schedule extends AppModel
{
	public $name = 'Schedule';
	public $primaryKey = 'id';
	public $actsAs = array('Containable');	

	public $belongsTo = array(
		'DepartureAirport' =&gt; array(
			'className' =&gt; 'Airport',
			'foreignKey' =&gt; false,
			'conditions' =&gt; 'DepartureAirport.icao = Schedule.departure_icao',
			'fields' =&gt; '',
			'order' =&gt; ''
		),

		'ArrivalAirport' =&gt; array(
			'className' =&gt; 'Airport',
			'foreignKey' =&gt; false,
			'conditions' =&gt; 'ArrivalAirport.icao = Schedule.arrival_icao',
			'fields' =&gt; '',
			'order' =&gt; ''
		)
	);
}
</pre>
<p>So we used the $belongTo relationship, and we will define two relationships &#8211; &#8220;DepartureAirport&#8221; and &#8220;ArrivalAirport&#8221;. We also select the class we will use (which IMO, should really be called &#8220;modelName&#8221; or &#8220;useModel&#8221;, that really tripped me up, but I digress). Next, we define the conditions &#8211; we&#8217;ll use the relationship name (DepartureAirport or ArrivalAirport), and the column name, along with the column name on the current table it should join on. And that&#8217;s pretty much it. You don&#8217;t really need a relationship on the &#8220;receiving&#8221; end (the Airports table), unless you will be querying airports, and finding out what schedules go there. I&#8217;ll leave that upto you <img src='http://nsslive.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>And then for the query itself:</p>
<pre class="brush: php;">
$this-&gt;Schedule-&gt;contain('DepartureAirport', 'ArrivalAirport');
$schedule = $this-&gt;Schedule-&gt;find('first');

// Our Airport specific data will be contained in:
$schedule['DepartureAirport']
$schedule['ArrivalAirport']
</pre>
<p>Which will now return something like (etc fields ommitted):</p>
<pre class="brush: plain;">
Array
(
	[Schedule] =&gt; Array
		(
			[schedule_id] =&gt; 4178
			[airline_id] =&gt; 2
			[code] =&gt; AEA
			[flightnum] =&gt; 6371
			[depicao] =&gt; CYUL
			[arricao] =&gt; KJFK
		)

	[DepartureAirport] =&gt; Array
		(
			[airport_id] =&gt; 597
			[iata] =&gt; YUL
			[icao] =&gt; CYUL
			[name] =&gt; Montreal / Pierre Elliot Trudeau International Airport, Quebec
			[timezone] =&gt; US/Eastern
			[location] =&gt; Montreal QC Canada
			[lat] =&gt; 45.470556
			[lng] =&gt; -73.740833
		)

	[ArrivalAirport] =&gt; Array
		(
			[airport_id] =&gt; 268
			[iata] =&gt; JFK
			[icao] =&gt; KJFK
			[name] =&gt; JFK Airport
			[timezone] =&gt; US/Eastern
			[location] =&gt; New York-Kennedy NY
			[lat] =&gt; 40.6398262
			[lng] =&gt; -73.7787443
		)

)
</pre>
<p>Note how it's using the <a href="http://book.cakephp.org/view/474/Containable" target="_new">Containable</a> behavior; this is so it doesn't pull every relationship you've defined with that table (the schedules table above has many more relationships, but for brevity, I only pulled the relevant ones). Not specifying Containable() is REALLY expensive, especially when you don't need all those relationships to be included in every time! To speed it up even more, you should specify the actual field names to pull (the SQL * operator is expensive). </p>
]]></content:encoded>
			<wfw:commentRss>http://nsslive.net/2009/07/02/cakephp-models-multiple-columns-to-the-same-table/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>ezDB and PHP 5.3</title>
		<link>http://nsslive.net/2009/06/30/ezdb-and-php-5-3/</link>
		<comments>http://nsslive.net/2009/06/30/ezdb-and-php-5-3/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 22:21:58 +0000</pubDate>
		<dc:creator>Nabeel</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://nsslive.net/?p=191</guid>
		<description><![CDATA[As-per Justin&#8217;s request, I&#8217;ve renamed by fork of ezSQL to ezDB. I&#8217;ve updated the github links, it&#8217;s now:
http://github.com/nshahzad/ezdb/
This will include changes to the class names, to keep it all even (ezSQL to ezDB). I&#8217;m working on APC caching right now, since that&#8217;s what I&#8217;m using on current project.
PHP 5.3 was also released today! This is [...]]]></description>
			<content:encoded><![CDATA[<p>As-per Justin&#8217;s request, I&#8217;ve renamed by fork of ezSQL to ezDB. I&#8217;ve updated the github links, it&#8217;s now:</p>
<p><a href="http://github.com/nshahzad/ezdb/">http://github.com/nshahzad/ezdb/</a></p>
<p>This will include changes to the class names, to keep it all even (ezSQL to ezDB). I&#8217;m working on APC caching right now, since that&#8217;s what I&#8217;m using on current project.</p>
<p>PHP 5.3 was also released today! This is an exciting release &#8211; with the addition of namespaces and __callStatic(), the static DB class will be much easier to work with (instead of replicating every function). I will be finishing up the 5.2 release first, and then subsequent releases and features, I think I will be posting to the PHP 5.3 release only, unless there&#8217;s demand to back-port it all.</p>
<p>I&#8217;ll also be implementing some features from CakePHP&#8217;s ORM, such as &#8220;findBy{ColumnName}({tablename})&#8221;, and other simple lookups. I&#8217;ve been using Cake alot too, and it&#8217;s a great framework.<br />
Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://nsslive.net/2009/06/30/ezdb-and-php-5-3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ezSQL updates</title>
		<link>http://nsslive.net/2009/06/29/ezsql-updates/</link>
		<comments>http://nsslive.net/2009/06/29/ezsql-updates/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 18:25:01 +0000</pubDate>
		<dc:creator>Nabeel</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://nsslive.net/?p=187</guid>
		<description><![CDATA[Well, got github working great. Did an update today, including:

$allowed_columns parameter for quick_insert() and quick_update(). So you can pass in $_POST or $_GET, as well as a list of valid indices to use
(optional) Exception handling with try/catch (more info)
Set return type (object, associative array, numeric array) globally through $default_type

Also, I&#8217;m updating the wiki slowly, transferring [...]]]></description>
			<content:encoded><![CDATA[<p>Well, got github working great. Did an update today, including:</p>
<ul>
<li>$allowed_columns parameter for quick_insert() and quick_update(). So you can pass in $_POST or $_GET, as well as a list of valid indices to use</li>
<li>(optional) Exception handling with try/catch (<a href="http://wiki.github.com/nshahzad/ezsql/error-handling">more info</a>)</li>
<li>Set return type (object, associative array, numeric array) globally through $default_type</li>
</ul>
<p>Also, I&#8217;m updating the wiki slowly, transferring all the useful information onto there, since it&#8217;s easy to keep everything together.</p>
<p>Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://nsslive.net/2009/06/29/ezsql-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ezSQL on github</title>
		<link>http://nsslive.net/2009/06/28/ezsql-on-github/</link>
		<comments>http://nsslive.net/2009/06/28/ezsql-on-github/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 21:41:38 +0000</pubDate>
		<dc:creator>Nabeel</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://nsslive.net/?p=184</guid>
		<description><![CDATA[Learning how to use github, so I created a repo for ezSQL.
http://github.com/nshahzad/ezdb
I plan on creating another version (a fork I guess?) for PHP 5.3 when it hopefully launches next week. It&#8217;ll have proper namespace support. Haven&#8217;t gotten to memcache just yet (hey, been busy!  , but at least there&#8217;s an easier route of distribution [...]]]></description>
			<content:encoded><![CDATA[<p>Learning how to use github, so I created a repo for ezSQL.</p>
<p><a href="http://github.com/nshahzad/ezdb">http://github.com/nshahzad/ezdb</a></p>
<p>I plan on creating another version (a fork I guess?) for PHP 5.3 when it hopefully launches next week. It&#8217;ll have proper namespace support. Haven&#8217;t gotten to memcache just yet (hey, been busy! <img src='http://nsslive.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , but at least there&#8217;s an easier route of distribution now.</p>
]]></content:encoded>
			<wfw:commentRss>http://nsslive.net/2009/06/28/ezsql-on-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backups are important!</title>
		<link>http://nsslive.net/2009/05/13/backups-are-important/</link>
		<comments>http://nsslive.net/2009/05/13/backups-are-important/#comments</comments>
		<pubDate>Thu, 14 May 2009 01:06:42 +0000</pubDate>
		<dc:creator>Nabeel</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://nsslive.net/?p=181</guid>
		<description><![CDATA[A huge flight sim site was hacked and destroyed this weekend  &#8211; avsim.com. An important lesson on why off-site backups are critical! They had two servers, and had a backup of A on B, and B on A. Both were taken out.
Ouch. A shame to see it go. I&#8217;ve been going there for 6/7 years [...]]]></description>
			<content:encoded><![CDATA[<p>A huge flight sim site was hacked and destroyed this weekend  &#8211; avsim.com. An important lesson on why off-site backups are critical! They had two servers, and had a backup of A on B, and B on A. Both were taken out.</p>
<p>Ouch. A shame to see it go. I&#8217;ve been going there for 6/7 years now. Good luck to them in getting it back up&#8230; they had one of the largest file libraries around.</p>
]]></content:encoded>
			<wfw:commentRss>http://nsslive.net/2009/05/13/backups-are-important/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss><!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
