<?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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Sohaib's Blog - A Cake-PHP Web Developer, Pakistan</title>
	
	<link>http://blog.sohaibmuneer.com</link>
	<description>Web Development in Web Standards and CakePHP</description>
	<pubDate>Mon, 22 Nov 2010 20:14:08 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</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/SohaibsBlog-CakePHPBaker" /><feedburner:info uri="sohaibsblog-cakephpbaker" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Underpaid Developers ? My Ass !!</title>
		<link>http://feedproxy.google.com/~r/SohaibsBlog-CakePHPBaker/~3/94Gg2X3TpxQ/underpaid-developers-my-ass</link>
		<comments>http://blog.sohaibmuneer.com/underpaid-developers-my-ass#comments</comments>
		<pubDate>Mon, 22 Nov 2010 20:10:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Life]]></category>

		<category><![CDATA[yelly pad]]></category>

		<category><![CDATA[developers]]></category>

		<category><![CDATA[pakistan]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[underpaid]]></category>

		<guid isPermaLink="false">http://blog.sohaibmuneer.com/?p=120</guid>
		<description><![CDATA[Yup ! I'm blogging after a loonngggg time ! First I started with a comment but then soon realized a post is due for this subject. Thanks to the author of this post !
When "Code Week" was launched I had some different expectations from these guys. I think the name mislead me and I thought [...]]]></description>
			<content:encoded><![CDATA[<p>Yup ! I'm blogging after a loonngggg time ! First I started with a comment but then soon realized a post is due for this subject. <a href="http://www.codeweek.pk/2010/11/underpaid-developers-dunning-and-kruger-explain-why/" target="_blank">Thanks to the author of this post</a> !</p>
<p>When "<a href="http://www.codeweek.pk/" target="_blank">Code Week</a>" was launched I had some different expectations from these guys. I think the name mislead me and I thought that finally some people are going to blog about actual "code" here in Pakistan ... how wrong was I <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> - I guess no one would be interested in "code" here. It's disappointing for a guy like me =/ but then again, what these guys at Code Week are rolling out is nice <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> because it's still unique in Pakistan (guys, just being honest, you are doing great work ! - kudos ! ).</p>
<p>Ok so enough of the prelude. I have been in the freelance "developing" scene for some 3 years now. I think may be I was lucky that I did not start out with a local firm. I was hired by a firm in Canada at first, after that I started working on contracts with firms abroad. This is where I really learned a lot !!!</p>
<p>I tried my luck here in a local firm, the employers were great ! but sadly did not work out. I was looking at a very long time after which I could get some good help. And by good I mean those who could learn quickly and to do that, they at least should have clear concepts of the programming world. Tough luck there <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> and it's out of that experience I rant ... "underpaid developers ?? - MY ASS !!"</p>
<p>Of all the tiny experience I have had till now, I really don't think developers here in Pakistan are underpaid. The kind of normal pays the developers are getting in the Pakistani market are justified because they are proportional to the technical competency they are getting.</p>
<p>In my opinion, a 100K / month plus salary package would be normal to qualify as good. But such an individual should know "Programming" should be willing to learn new things with a relatively shorter learning curve. Someone who would know the importance of following standards and most of all, should know "WHY" the standards are implemented in the first place. And should abide by the deadlines he / she gives (unless something changes drastically of course). And should "know" how to "really" use a framework or two to their fullest potential. This person should NOT chicken out if work is desired in some other programming language / technology.</p>
<p>For instance, I asked some developers here to try Python for a change. And told them that if they are willing I could make sure they learn it on the company's time (as personal learning / growth was an important factor). The company could have scored some base level projects in Python, and as their experience would have grown, there could have been more challenging and more high paying projects on the table. But sadly their blood turned white as if I asked them to go shoot themselves .... and that is something I did not understand (and still don't).<br />
In the developing business, if you are not flexible enough to try new things, you are more likely to be found whining that you are "underpaid". Of course you are ! ... if you are working in PHP and you can't even wrap your head around a good PHP-framework then you are not good at all !!</p>
<p>The author on Code Week's post is the first person I have seen who has meaningfully used Maslow's four stages of learning. And he very "kindly" suggests that if you are whining then "may be" you are not that good. Kudos for his kindheartedness, but I am saying this out loud ! ... please asses yourself if you are technically competent or not. To assess yourself, you would need to see that if you feel threatened by new technologies and if you feel that you cannot understand and utilize new and / or non-conventional concepts, then I'm sorry, you should be glad you still have a job. Because if you were in some place like the U.S.A you would have been out of a job real soon.<br />
I can accept that being "underpaid" could be a genuine case in a country like U.S.A because there are a lot of good developers there and the competition is not tough, it's a ball breaker for sure ! ... so either you are good or unemployed, or working for chump change. It's as simple as that.</p>
<p>I have seen people claiming 5 years of experience to turn out useless, whereas a motivated kid, doing some programming in his extra time during his studies, turning out to be a rock star developer. Having X amount of experience as a software developer does not necessarily make you more technically competent.</p>
<p>The dilemma of the employers here is that they can't earn much because their workforce is not up to the mark. They might be able to find one or two good guys, but retaining them would be a problem. And the biggest problem would be to pay them handsomely whilst paying the others normally. And only the good firms are facing this dilemma here. The others, well, they are a BIG part of the problem. The reason is, they hire fresh grads, and put them on DUMB tasks. They really don't give a shit about their learning and personal growth. They just squeeze the juice out of them for a year or two and when they go about applying in other firms, they have a highlighted line on their CV saying "3 years of experience" or something like that. But it's useless.</p>
<p>On the bright side, I know some developers here in Pakistan who are freelancers and yes ! ... they ARE good at what they do and this is exactly the reason why they are hired and RETAINED by employers abroad. They get paid handsomely, a pay scale which the employers here cannot even think of matching. So the employers here MUST realize that they are in a global competition and they should at least spend on training fresh grads so that they come up to a good mark and let them meet deadlines with quality code <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>And oh ! ... if you are a software developer and you don't take pride in your work, then your definitely doomed !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sohaibmuneer.com/underpaid-developers-my-ass/feed</wfw:commentRss>
		<feedburner:origLink>http://blog.sohaibmuneer.com/underpaid-developers-my-ass</feedburner:origLink></item>
		<item>
		<title>CakePHP Auto Magic Search Conditions</title>
		<link>http://feedproxy.google.com/~r/SohaibsBlog-CakePHPBaker/~3/27Fvc2toC6o/cakephp-auto-magic-search-conditions</link>
		<comments>http://blog.sohaibmuneer.com/cakephp-auto-magic-search-conditions#comments</comments>
		<pubDate>Mon, 05 Jul 2010 12:41:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[CakePHP]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.sohaibmuneer.com/?p=112</guid>
		<description><![CDATA[Hey folks, so this is a nifty trick I implemented after being inspired from overriding CakePHP Model::find(). There's nothing to it really, just making use of the extreme flexibility CakePHP's architecture allows, provided you wrap your head around the CakePHP way of doing things  
Before commencing, I would really advise anyone out there who [...]]]></description>
			<content:encoded><![CDATA[<p>Hey folks, so this is a nifty trick I implemented after being inspired from overriding CakePHP Model::find(). There's nothing to it really, just making use of the extreme flexibility CakePHP's architecture allows, provided you wrap your head around the CakePHP way of doing things <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Before commencing, I would really advise anyone out there who wants to make it to a good level in CakePHP to read <a href="http://www.pseudocoder.com/free-cakephp-book/">Matt's book</a>. To make this post shorter I will assume that you fully understand how to override Model::find() for CakePHP as Matt explains in his book as "My Way". These are the functions that you will need:</p>
<div style="width:100%;overflow:auto;">
<pre class="php"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">class</span> AppModel <span style="color: #000000; font-weight: bold;">extends</span> Model <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #0000ff;">$searchValues</span> = <span style="color: #000000; font-weight: bold;">null</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> searchCondition <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$type</span>, <span style="color: #0000ff;">$options</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #0000ff;">$type</span> = <a href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'-'</span>, <span style="color: #ff0000;">'_'</span>, <span style="color: #0000ff;">$type</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #0000ff;">$method</span> = <a href="http://www.php.net/sprintf"><span style="color: #000066;">sprintf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'__sc%s'</span>, Inflector::<span style="color: #006600;">camelize</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$type</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/method_exists"><span style="color: #000066;">method_exists</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$this</span>, <span style="color: #0000ff;">$method</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<a href="http://www.php.net/trigger_error"><span style="color: #000066;">trigger_error</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Method '</span>.<span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">name</span>.<span style="color: #ff0000;">'::'</span>.<span style="color: #0000ff;">$method</span>.<span style="color: #ff0000;">'() Does Not Exist'</span>, <span style="color: #000000; font-weight: bold;">E_USER_ERROR</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000ff;">$method</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$options</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> searchConditions<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #0000ff;">$conds</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">searchValues</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$val</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #0000ff;">$_conds</span> = <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">searchCondition</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$val</span>, <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #0000ff;">$conds</span> = am<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$conds</span>, <span style="color: #0000ff;">$_conds</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$conds</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">class</span> User <span style="color: #000000; font-weight: bold;">extends</span> AppModel <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	protected <span style="color: #000000; font-weight: bold;">function</span> __scAge <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$options</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #0000ff;">$age</span> = Set::<span style="color: #006600;">classicExtract</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">searchValues</span>, <span style="color: #ff0000;">'age'</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #0000ff;">$ageComp</span> = Set::<span style="color: #006600;">classicExtract</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">searchValues</span>, <span style="color: #ff0000;">'age_comparison'</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #0000ff;">$conds</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/empty"><span style="color: #000066;">empty</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$age</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; <a href="http://www.php.net/is_numeric"><span style="color: #000066;">is_numeric</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$age</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; !<a href="http://www.php.net/empty"><span style="color: #000066;">empty</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ageComp</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #0000ff;">$dob</span> = <a href="http://www.php.net/date"><span style="color: #000066;">date</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Y-m-d'</span>, <a href="http://www.php.net/strtotime"><span style="color: #000066;">strtotime</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;-$age years&quot;</span>, <a href="http://www.php.net/strtotime"><span style="color: #000066;">strtotime</span></a><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/date"><span style="color: #000066;">date</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Y-m-d'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #0000ff;">$ageConds</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				<span style="color: #ff0000;">'&gt;'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'User.dob &gt;'</span> =&gt; <span style="color: #0000ff;">$dob</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				, <span style="color: #ff0000;">'&lt;'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'User.dob &lt;'</span> =&gt; <span style="color: #0000ff;">$dob</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				, <span style="color: #ff0000;">'='</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'User.dob'</span> =&gt; <span style="color: #0000ff;">$dob</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #0000ff;">$conds</span> = <span style="color: #0000ff;">$ageConds</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$ageComp</span><span style="color: #66cc66;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$conds</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">class</span> UsersController <span style="color: #000000; font-weight: bold;">extends</span> AppController <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> search<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #0000ff;">$data</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">RequestHandler</span>-&gt;<span style="color: #006600;">isPost</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> || <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">RequestHandler</span>-&gt;<span style="color: #006600;">isPput</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">User</span>-&gt;<span style="color: #006600;">searchValues</span> = <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">data</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'User'</span><span style="color: #66cc66;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #0000ff;">$conditions</span> = <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">User</span>-&gt;<span style="color: #006600;">searchConditions</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #0000ff;">$data</span> = <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">User</span>-&gt;<span style="color: #006600;">find</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'all'</span>, <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'contain'</span>=&gt;false, <span style="color: #ff0000;">'conditions'</span>=&gt;<span style="color: #0000ff;">$conditions</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
</div>
<p>Hold on ... don't panic, I assure you it's quite simple <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> - First off, the AppModel::searchCondition() will generate the condition for you and you would need to write up the proper conditions within the model itself which is the User model in our case.<br />
As you will notice that I am trying to find the "age" of the particular user. I only have the User's date of birth stored as "dob" field in the users table. There is NO "age" field in the users table of course. So in essence, you may or may not relate actual field names of the table. This is what makes it really powerful. And this is what can allow me to find a User's age via more than 1 way. This is a very simple demonstration what can be done. For reasons of simplicity I have not used the $options variable which you will see as the second parameter of the AppModel::searchCondition(). In the code above you will see only the 'conditions' being returned, in my actual implementations I return all the options of a normal Model::find() call. That allows me to set joins and any virtual fields I like. It's pretty nifty once you dwell on the whole process.</p>
<p>I can simply write up another search condition filter in my User model,</p>
<div style="width:100%;overflow:auto;">
<pre class="php"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	protected <span style="color: #000000; font-weight: bold;">function</span> __scOlderThan<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$options</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #0000ff;">$age</span> = Set::<span style="color: #006600;">classicExtract</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">saerchValues</span>, <span style="color: #ff0000;">'order_than'</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #0000ff;">$conds</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/empty"><span style="color: #000066;">empty</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$age</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; <a href="http://www.php.net/is_numeric"><span style="color: #000066;">is_numeric</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$age</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #0000ff;">$conds</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;(DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS(User.dob)), '%Y')+0) &gt; $age&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$conds</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
</div>
<p>And this would work if I supply a valid numeric value in "older_than" field I can create on the fly using the FormHelper in my form so this would be supplied as Controller::data['User']['older_than'] in the controller.</p>
<p>You can easily follow this concept and play with the code to also include all the options in the Model::find() call as I've mentioned above. When you do this, retrieving data sets becomes a breeze ! ... It's like you tame your model to behave the way you want whenever the particular fields are given !</p>
<p>P.S. shoot ! ... so this post I've tried to put together under too many distractions <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> ... I hope I make it clear though.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sohaibmuneer.com/cakephp-auto-magic-search-conditions/feed</wfw:commentRss>
		<feedburner:origLink>http://blog.sohaibmuneer.com/cakephp-auto-magic-search-conditions</feedburner:origLink></item>
		<item>
		<title>My Conscience - The Word Salad</title>
		<link>http://feedproxy.google.com/~r/SohaibsBlog-CakePHPBaker/~3/7V9V_7yIKQA/my-concious-the-word-salad</link>
		<comments>http://blog.sohaibmuneer.com/my-concious-the-word-salad#comments</comments>
		<pubDate>Thu, 18 Mar 2010 02:26:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Life]]></category>

		<category><![CDATA[yelly pad]]></category>

		<guid isPermaLink="false">http://blog.sohaibmuneer.com/?p=104</guid>
		<description><![CDATA[People, I know I am a lousy blogger. I seldom update my blog. I always thought I would be writing about technology on my blog ... but so much for that ! ... There are things that move me ... and these things I see a lot these days. Reminds me of a song "Affirmation" [...]]]></description>
			<content:encoded><![CDATA[<p>People, I know I am a lousy blogger. I seldom update my blog. I always thought I would be writing about technology on my blog ... but so much for that ! ... There are things that move me ... and these things I see a lot these days. Reminds me of a song "Affirmation" by "Savage Garden":</p>
<blockquote><p><span style="font-family: mceinline;"><em>When Super stars and cannon balls are running through your head,</em></span></p>
<p><span style="font-family: mceinline;"><em>Television freak shows, cops and robbers every where,</em></span></p>
<p><span style="font-family: mceinline;"><em>the subway makes me nervous, people pushing me too far,</em></span></p>
<p><span style="font-family: mceinline;"><em>I'd like to break away so take my hand now ...</em></span></p></blockquote>
<blockquote><p><span style="font-family: mceinline;"><em>coz I want to LIVE ... LIKE ANIMALS ... CARELESS AND FREEE !!</em></span></p>
<p><span style="font-family: mceinline;"><em>I want to run to the jungle with the winds in my hair and sand at me feeeettt ...</em></span></p></blockquote>
<p>This is the kind of final resort I find to break away from these things that bug me. It's a temporary la la land at least I tend to go into, escape reality for a while. When thinking with a sound rational mind, my reactions are quite contrary, in fact, quite measured. YES ! I am a believer ! ... and I think either your ARE one or you are NOT. There is no rational reasoning behind God. Rationale, in my opinion, FAILS to provide rationale for itself, but that is something I wish to save for another post.</p>
<p>So what really is up in my screwed up head ? ... It's all those things that I see very important in a society to be sound and be the least hypocritical. Ours, however, is NOT. We display an array of issues that make us anything BUT sane. And that is EXACTLY what tickles my sanity. Heck, in my plight, I might be on the verge of acting out completely IRRATIONAL and that's only because I am HUMAN.</p>
<p>My beef with the society I live in is very simple. WHY THE FUCK DON'T YOU LIVE UP TO EVEN THE GRAVEST PRINCIPLES WE PROMISED OUR SOCIETY WOULD BE AFTER GAINING INDEPENDENCE ?</p>
<p>I cannot take it anymore. I tend to take these issues HEAD ON ... soliloquy with my own self on my blog and find out the right and wrong while doing it. Honesty as they say, IS the best policy no ? ...</p>
<p>Our judicial system is pretty fucked up. All our major organizations of the state present a picture of a one big clusterfuck ! ... name any department that is disciplined (except perhaps the Army) ? any department that acts in a way that it serves social justice in it's field ? ... ok, granted that it does not do so fully, but how about even minutely ? ... fuck ! ... none of them does !</p>
<p>Any Pakistani who is reading this, it is my sincerest plea to you that PLEASE ... YOU MUST REALIZE THAT THE RESPONSIBILITY SETS UPON US ! ... we claim, and we blame external *powers* for our plight ... but please think about it ... who gave them the opportunity ? ... who provided temptation ? ... WHO is in CONTEMPT of first Kalimah ? ... yes folks, thats us. And we are reaping of what we have sown. We shouldn't be whining about that.</p>
<p>But the fact of the matter is, it's not too late. Even after breaking our county (fall of Dhaka ... remember ? ... o yes, most of you reading this wouldn't have been born till that day ... I wasn't too) have we learned ? ... I guess only a little. But we must strive to learn more.</p>
<p>Start asking yourselves what YOUR role in the society is, instead of trying to point fingers at one another. Execute that role and PAY IT FORWARD ! ... it's absolutely important that we pay it forward !</p>
<p>Please realize the fact that DARKNESS PREVAILS WHEN GOOD MEN FAIL TO ACT ! ... our whole system has plunged into darkness because of that. And what are we waiting for ? ... a Mustafa Kamal Atta-turk ? ... who would beat the crap out of fucking Mullahs ? ... I guess, even if we weren't, we might need one.</p>
<p>It is based on religion that these Mullahs of today have so successfully captivated us, made us "zehni ghulam" (mind slaves) and then used us to serve their own bullshit purposes. Reminds of the time I read how Europe was like when the Church was dominant. But of course, they learned that the Church was nothing but bad news so they banned it from their lives and their constitution. Would we do that ? ... It certainly won't be the most wise thing to do. If we could just only be HUMAN first we can solve all most if not all our problems.</p>
<p>Without further a do (which means bullshit) my conscious is really fucked up. It CANNOT figure out who is at fault besides our own selves, so it has dropped the idea altogether. It has thought and thought and thought about the current times. It has found no one at fault only but our own selves. It is full and it has exploded already ... and now ceasing to exist very soon.</p>
<p>I think to save my sanity I'd be better off WITHOUT a conscious in our society. I'd be better off letting small and petty issues like honesty bug me. After all, this "conscience" is creating a havoc in my life ... this "conscience" ... folks ... really is a menace isn't it ?</p>
<p>Fuck Thy Conscious For Thy Sanity ! ... and that is a deal I would make again in a heart beat ! ... over and out !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sohaibmuneer.com/my-concious-the-word-salad/feed</wfw:commentRss>
		<feedburner:origLink>http://blog.sohaibmuneer.com/my-concious-the-word-salad</feedburner:origLink></item>
		<item>
		<title>Using MySQL INNER JOIN in CakePHP Pagination</title>
		<link>http://feedproxy.google.com/~r/SohaibsBlog-CakePHPBaker/~3/k43IhLxhouk/using-mysql-inner-join-in-cakephp-pagination</link>
		<comments>http://blog.sohaibmuneer.com/using-mysql-inner-join-in-cakephp-pagination#comments</comments>
		<pubDate>Wed, 04 Nov 2009 19:05:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[CakePHP]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Pagination]]></category>

		<guid isPermaLink="false">http://blog.sohaibmuneer.com/?p=70</guid>
		<description><![CDATA[First of all, I've got to hand it over to Matt he really did a BBBIIIGGG favor to the CakePHP community by publishing his guide to advanced CakePHP Techniques. This guide / book will give a great insight into the framework to anyone who is a seasoned programmer and is picking up Cake for the [...]]]></description>
			<content:encoded><![CDATA[<p>First of all, I've got to hand it over to <a href="http://pseudocoder.com" target="_blank">Matt</a> he really did a BBBIIIGGG favor to the CakePHP community by publishing his <a href="http://www.pseudocoder.com/free-cakephp-book/" target="_blank">guide to advanced CakePHP Techniques</a>. This guide / book will give a great insight into the framework to anyone who is a seasoned programmer and is picking up Cake for the first or so time. And I'm going to be floating ideas to compliment the advanced techniques and all in all promote good programming practices of what I'm aware of.</p>
<p>Now, I've seen a lot of shitty code when it comes to CakePHP. Yes, I've even seen mysql_query() calls in views ! ... yes, I've lived that day and kept my sanity in tact. But I can't blame the programmers too because obviously they were newbies and were under a lot of pressure to "get things going" by their blood sucking employers. Anyhoo ... this might be the subject of another post, BUT I really had to get it out of my system ... *phew* ... feel so light now <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So, MySQL INNER JOINS ... when should you use them ? - simple answer: when you want to filter out data in your result set. And it's quicker than filtering out results in the "WHERE" clause. Don't have any metrics to show to support this conclusion right now, but I speak in the light of many tests I've conducted on large datasets. A more simpler theory is that the "WHERE" clause needs to filter out a lot more rows in a result-set obtained as a result of using "LEFT JOIN". CakePHP's logic however is sound to use LEFT JOIN as the intention is not to filter out the records, it's merely to include whichever records belongs to the conditions you supply. That's why it's "Containable" behavior is so cool (special thanks to <a href="http://debuggable.com/about" target="_blank">Felix</a> on that for maturing it and making a part of the Cake's core).</p>
<p>The more you familiarize yourself with Cake's datasource classes the better. The most excellent example was published on the bakery by Nate on <a href="http://bakery.cakephp.org/articles/view/quick-tip-doing-ad-hoc-joins-in-model-find" target="_blank">how to use JOINs in CakePHP</a>. I think this should be made part of the documentation too. This could actually make you get rid of "overriding" Controller::paginate() function. When you come to know about the flexibility offerred by the datasource class you love it even more <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> - a simple example:</p>
<div style="width:100%;overflow:auto;">
<pre class="php"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">class</span> PostsController <span style="color: #000000; font-weight: bold;">extends</span> AppController <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> by_tag <span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$tag</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;   * This will fetch Posts tagged $tag (say, 'PHP')</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;   */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">paginate</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'Post'</span><span style="color: #66cc66;">&#93;</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      <span style="color: #ff0000;">'limit'</span> =&gt; <span style="color: #cc66cc;">10</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      , <span style="color: #ff0000;">'contain'</span> =&gt; <span style="color: #ff0000;">''</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      , <span style="color: #ff0000;">'conditions'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">       <span style="color: #ff0000;">'Post.published'</span> =&gt; <span style="color: #cc66cc;">1</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      <span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      , <span style="color: #ff0000;">'fields'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Post.*'</span>, <span style="color: #ff0000;">'Tag.*'</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      , <span style="color: #ff0000;">'joins'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">          <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #ff0000;">'table'</span> =&gt; <span style="color: #ff0000;">'posts_tags'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            , <span style="color: #ff0000;">'type'</span> =&gt; <span style="color: #ff0000;">'INNER'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            , <span style="color: #ff0000;">'alias'</span> =&gt; <span style="color: #ff0000;">'PostTag'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            , <span style="color: #ff0000;">'conditions'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                <span style="color: #ff0000;">'Post.id = PostTag.post_id'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">          <span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">          , <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #ff0000;">'table'</span> =&gt; <span style="color: #ff0000;">'tags'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            , <span style="color: #ff0000;">'alias'</span> =&gt; <span style="color: #ff0000;">'Tag'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            , <span style="color: #ff0000;">'type'</span> =&gt; <span style="color: #ff0000;">'INNER'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            , <span style="color: #ff0000;">'conditions'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                <span style="color: #ff0000;">&quot;PostTag.tag_id = Tag.id AND Tag.name = '$tag'&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">          <span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      <span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      <span style="color: #0000ff;">$data</span> = <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">paginate</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Post'</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/compact"><span style="color: #000066;">compact</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'data'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
</div>
<p>This is just a simple example of what you can achieve by adding simple joins in your Model::find() conditions and of course in the paginate part. I've stretched it a bit further. I've actually used sub-queries and sub-joins, really complex stuff when paginating some complex data sets. Thanks to the 'joins' I never had to override the Controller::paginate() method ever. Just for the sake of example, let's say I want to retrieve posts tagged in 'PHP' and 'CakePHP' written by users who have a rating above 3. Of course this can be done in other ways, here is one using a sub-query join in CakePHP elegantly:</p>
<div style="width:100%;overflow:auto;">
<pre class="php"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// work this out wherever you want it - in your model or controller</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// but if I were you, I'd put this in my model</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$join</span> = <span style="color: #ff0000;">&quot;SELECT posts.id AS POST_ID FROM posts JOIN authors ON (posts.author_id = authors.id)&quot;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$join</span> = <span style="color: #0000ff;">$join</span>.<span style="color: #ff0000;">' '</span>.<span style="color: #ff0000;">&quot;JOIN users_ratings ON (authors.user_id = users_ratings.user_id AND users_ratings.rating &gt; 3)&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$join</span> = <span style="color: #0000ff;">$join</span>.<span style="color: #ff0000;">' '</span>.<span style="color: #ff0000;">&quot;WHERE 1=1&quot;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><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;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// in your controller</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">paginate</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'Post'</span><span style="color: #66cc66;">&#93;</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #ff0000;">'limit'</span> =&gt; <span style="color: #cc66cc;">10</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  , <span style="color: #ff0000;">'contain'</span> =&gt; <span style="color: #ff0000;">''</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  , <span style="color: #ff0000;">'conditions'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">   <span style="color: #ff0000;">'Post.published'</span> =&gt; <span style="color: #cc66cc;">1</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  , <span style="color: #ff0000;">'fields'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Post.*'</span>, <span style="color: #ff0000;">'Tag.*'</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  , <span style="color: #ff0000;">'joins'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">'table'</span> =&gt; <span style="color: #ff0000;">'posts_tags'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        , <span style="color: #ff0000;">'type'</span> =&gt; <span style="color: #ff0000;">'INNER'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        , <span style="color: #ff0000;">'alias'</span> =&gt; <span style="color: #ff0000;">'PostTag'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        , <span style="color: #ff0000;">'conditions'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #ff0000;">'Post.id = PostTag.post_id'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      <span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      , <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">'table'</span> =&gt; <span style="color: #ff0000;">'tags'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        , <span style="color: #ff0000;">'alias'</span> =&gt; <span style="color: #ff0000;">'Tag'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        , <span style="color: #ff0000;">'type'</span> =&gt; <span style="color: #ff0000;">'INNER'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        , <span style="color: #ff0000;">'conditions'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #ff0000;">&quot;PostTag.tag_id = Tag.id AND Tag.name IN('PHP', 'CakePHP')&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      <span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      , <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">'table'</span> =&gt; <span style="color: #ff0000;">'('</span>.<span style="color: #0000ff;">$join</span>.<span style="color: #ff0000;">')'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        , <span style="color: #ff0000;">'alias'</span> =&gt; <span style="color: #ff0000;">'FILTERED_RESULTS'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        , <span style="color: #ff0000;">'type'</span> =&gt; <span style="color: #ff0000;">'INNER'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        , <span style="color: #ff0000;">'conditions'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #ff0000;">&quot;Post.id = FILTERED_RESULTS.POST_ID&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      <span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
</div>
<p>And this will elegantly filter out the posts you need <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p><strong>Conclusion:&nbsp;</strong> you can really write any kind of a query and really devise a condition based system that would add filters auto-magically. (I will present such a system in another post) - Remember, CakePHP is all about auto-magic ! ... which is actually the culmination of "convention over configuration" so use it to the fullest !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sohaibmuneer.com/using-mysql-inner-join-in-cakephp-pagination/feed</wfw:commentRss>
		<feedburner:origLink>http://blog.sohaibmuneer.com/using-mysql-inner-join-in-cakephp-pagination</feedburner:origLink></item>
		<item>
		<title>CakePHP Archivable Behavior</title>
		<link>http://feedproxy.google.com/~r/SohaibsBlog-CakePHPBaker/~3/IikDOxn5yv4/cakephp-archivable-behavior</link>
		<comments>http://blog.sohaibmuneer.com/cakephp-archivable-behavior#comments</comments>
		<pubDate>Tue, 03 Nov 2009 15:28:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[CakePHP]]></category>

		<category><![CDATA[MediaWiki]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Archivable]]></category>

		<category><![CDATA[Behaviors]]></category>

		<guid isPermaLink="false">http://blog.sohaibmuneer.com/?p=72</guid>
		<description><![CDATA[Alright folks ... yeh I know I've been out of the picture really long and me blog is looking deserted for real now. Anyhow, I've got a bunch of posts in the pipeline. Thanks to Ahmed of SoccerLens for convincing me to start posting again :).
Enough chit chat ... so the cool thing I bring [...]]]></description>
			<content:encoded><![CDATA[<p>Alright folks ... yeh I know I've been out of the picture really long and me blog is looking deserted for real now. Anyhow, I've got a bunch of posts in the pipeline. Thanks to <a href="http://ahmedbilal.com/" target="_blank">Ahmed</a> of <a href="http://soccerlens.com" target="_blank">SoccerLens</a> for convincing me to start posting again :).</p>
<p>Enough chit chat ... so the cool thing I bring you here my friends is this Behavior I just baked up for a client. The Archivable Behavior. I love CakePHP's behavior architecture and had <a href="http://cake-syrup.sourceforge.net/ingredients/soft-deletable-behavior/ " target="_blank">Mariano Iglesias's SoftDeletable</a> behavior in mind before baking this baby.</p>
<h3><strong>What it does ?</strong></h3>
<p>It simply puts the record you want to delete in another table. I see no use bloating my existing table by adding a "deleted" field, especially when it would need to go through this process many times. Imagine, how big your table would get when you simply soft delete a record and it just sits there and is rarely used. I've seen this kind of methodology run into trouble when you are search the table. MySQL has to go through a lot of unwanted, deleted records and extract the active ones, it slows down the search process, especially when you are using UUIDs.</p>
<h3><strong>Usage:</strong></h3>
<p>This example follows for a Model, say, "MyPosts".</p>
<p><code><br />
public $actsAs = array('Archivable'=&gt;array('table'=&gt;'my_posts_archives'));</code></p>
<p>If you don't specify a the table key, it will simply look for the table, 'my_posts_archived'. The schema for the archives table is simple. It's the same as the table my_posts but it has an additional field, my_post_id. You're going to have to create that table yourself. If you're like me and use PhPMyAdmin it should be really simple by going into <em>Table -&gt; Operations -&gt; copy</em>.</p>
<p>Once you're done with setting up the table and attaching the Archivable behavior with your model, anytime you execute the statement $this-&gt;MyPost-&gt;del($id); it will simply move the record from my_posts table to my_posts_archives table.<br />
You can also use $this-&gt;MyPost-&gt;unarchive($id); to achieve reverse, i.e. remove the archived record from the archive table and move it back to the main table. As simple as that ! <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<h3><strong>Notes:</strong></h3>
<p>I've baked this on CakePHP 1.3.0.0 with PHP 5.2.4. Although this should run smooth on CakePHP 1.2.x too but if you are using PHP 5.3 you're gonna have to make some adjustments when objects are passed via reference in the code.</p>
<p><a href="http://blog.sohaibmuneer.com/downloads/archivable.php.zip">Download the Behavior</a></p>
<p>Have fun ya'all <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sohaibmuneer.com/cakephp-archivable-behavior/feed</wfw:commentRss>
		<feedburner:origLink>http://blog.sohaibmuneer.com/cakephp-archivable-behavior</feedburner:origLink></item>
		<item>
		<title>Integrating MediaWiki With CakePHP</title>
		<link>http://feedproxy.google.com/~r/SohaibsBlog-CakePHPBaker/~3/_WIQbKVskz0/integrating-mediawiki-with-cakephp</link>
		<comments>http://blog.sohaibmuneer.com/integrating-mediawiki-with-cakephp#comments</comments>
		<pubDate>Fri, 19 Jun 2009 01:28:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[CakePHP]]></category>

		<category><![CDATA[MediaWiki]]></category>

		<guid isPermaLink="false">http://blog.sohaibmuneer.com/?p=61</guid>
		<description><![CDATA[Hi Folks. As you might have guessed from the title, I was up trying to integrate MediaWiki with a CakePHP application of mine. Yeah, all hell did break loose while I was at it. As naive as it may sound, I was dreaming something like an API bridge between the MediaWiki and CakePHP. But like [...]]]></description>
			<content:encoded><![CDATA[<p>Hi Folks. As you might have guessed from the title, I was up trying to integrate MediaWiki with a CakePHP application of mine. Yeah, all hell did break loose while I was at it. As naive as it may sound, I was dreaming something like an API bridge between the <a href="http://www.mediawiki.org/">MediaWiki</a> and <a href="http://cakephp.org">CakePHP</a>. But like I said, it was a dream, and as the notion suggests, "so you wanna build an API bridge between MediaWiki and CakePHP in one night ?" - "DREAM ON SUCKER !" because you'll never find the time and the nerve to do it ... doh !</p>
<p>May be some day, if no one beats me to it, I'd get that bridge up and running. But till then let me explain a nifty way of doing this.</p>
<p>Your best chance to include a MediaWiki with your CakePHP application is via some RewriteRule magic in your .htaccess file. You simply need to specify which URL you want to be pointed to your wiki application. In my case, I simply wanted all http://mysite.com/wiki/ requests to map to /doc-root/wiki instead of /doc-root/app.</p>
<p>I usually don't keep the App folder type of structure in my CakePHP apps but this particular application was an exception. The concept is to:</p>
<blockquote><p>"read the URL you want pointing to the MediaWiki and change your document root to the folder where you are keeping the MediaWiki"</p></blockquote>
<p>Now, here is the file structure of my the application I was working on:</p>
<ul style="list-style: none;">
<li>/ &lt; app_name &gt;
<ul>
<li>/ branches
<ul>
<li>/ sohaib
<ul>
<li>/ app</li>
<li style="color:#CC0000;">.htaccess</li>
</ul>
</li>
<li>/ wiki
<ul>
<li>index.php</li>
<li style="color:#32DF00">.htaccess</li>
<li> ....</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>Say, like me, you want to get all URLs with "/wiki" to be directed to the MediaWiki app, then a small change you'll make int the .htaccess file highlighted in red above would be:</p>
<p><code><br />
RewriteEngine on<br />
RewriteRule		^(.*)/wiki/(.*)	wiki/		[NC]<br />
RewriteRule		^(.*)/wiki/(.*)	wiki/$1	[NC]<br />
RewriteRule		^$ app/webroot/		[L]<br />
RewriteRule		(.*) app/webroot/$1	[L]<br />
</code></p>
<p>This tells Apache to first look for URLs containing /wiki - and redirect these to to the /sohaib/wiki folder where another .htaccess file awaits the request (highlighted in green above). This file is identical to the one you can find in /webroot folder of your app. You can copy paste this file to your wiki folder.</p>
<p><code><br />
RewriteEngine On<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]<br />
</code></p>
<p>This connects your /wiki requests to the index.php file of your media wiki. And thats it as non-technical as I could be in trying to explain what you can do. I am not going into the exaplaination of the code in the .htaccess files. You'd be able to find good resources via google. But if you're like me, you'll settle for the documentation on mod_rewrite on Apache.org</p>
<p>But let me tell you, this is a very simple demonstration of what you can achieve with mod_rewrite ... this thing is COMPLEX and way too much voodoo, especially when regular expressions come into play. So be careful, it's addictive <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> - Hope this helps anyone out there trying to integrate a MediaWiki with their App. Over and OUT !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sohaibmuneer.com/integrating-mediawiki-with-cakephp/feed</wfw:commentRss>
		<feedburner:origLink>http://blog.sohaibmuneer.com/integrating-mediawiki-with-cakephp</feedburner:origLink></item>
		<item>
		<title>Free WordPress Themes by WooThemes</title>
		<link>http://feedproxy.google.com/~r/SohaibsBlog-CakePHPBaker/~3/oqYpiFSVB3M/free-wordpress-themes-by-woothemes</link>
		<comments>http://blog.sohaibmuneer.com/free-wordpress-themes-by-woothemes#comments</comments>
		<pubDate>Thu, 16 Apr 2009 00:21:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[yelly pad]]></category>

		<guid isPermaLink="false">http://blog.sohaibmuneer.com/?p=49</guid>
		<description><![CDATA[I just changed my blog theme to a really cool theme by WooThemes. At last ! I've found a decent theme and got rid of the all-black look I was using to protest my procrastination. At least this one has a simple and fresh look. So these are the downsides of not being a designer. [...]]]></description>
			<content:encoded><![CDATA[<p>I just changed my blog theme to a really cool theme by WooThemes. At last ! I've found a decent theme and got rid of the all-black look I was using to protest my procrastination. At least this one has a simple and fresh look. So these are the downsides of not being a designer. But I find it odd some times. Though I don't design but do I have an eye for it. Wonder which category I'd fall into ? - Some kind of warp zone between a design itself and a designer ... huh ?</p>
<p>I've gotta say, these guys have some really excellent themes. They are giving away some themes for free, I suggest you try em ! ... these guys got talent <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> - And also check out thier premium themes, they're really worth it. Hope you like em'</p>
<p>Here is a list of the free themes as of Thursday, April 16th, 2009:</p>
<p><span style="color: #003366;font-size:22px;line-height:52px;">Irresistable</span></p>
<p><a href="http://www.woothemes.com/2009/02/irresistible/" target="_blank"><img class="aligncenter size-full wp-image-50" title="irresistable" src="http://blog.sohaibmuneer.com/wp-content/uploads/2009/04/irresistable.png" alt="irresistable" width="424" height="320" /></a></p>
<p><span style="color: #003366;font-size:22px;line-height:52px;">Blog Theme</span></p>
<p><a href="http://www.woothemes.com/2008/11/blogtheme/" target="_blank"><img class="aligncenter size-full wp-image-51" title="blog-theme" src="http://blog.sohaibmuneer.com/wp-content/uploads/2009/04/blog-theme.png" alt="blog-theme" width="424" height="320" /></a></p>
<p><span style="color: #003366;font-size:22px;line-height:52px;">Snapshot</span></p>
<p><a href="http://www.woothemes.com/2008/10/snapshot/" target="_blank"><img class="aligncenter size-full wp-image-52" title="snapshot" src="http://blog.sohaibmuneer.com/wp-content/uploads/2009/04/snapshot.png" alt="snapshot" width="424" height="320" /></a></p>
<p><span style="color: #003366;font-size:22px;line-height:52px;">The Premium News</span></p>
<p><a href="http://www.woothemes.com/2007/11/the-original-premium-news/" target="_blank"><img class="aligncenter size-full wp-image-53" title="the-premium-news" src="http://blog.sohaibmuneer.com/wp-content/uploads/2009/04/the-premium-news.png" alt="the-premium-news" width="424" height="320" /></a></p>
<p><span style="color: #003366;font-size:22px;line-height:52px;">Typebased</span></p>
<p><a href="http://www.woothemes.com/2008/11/typebased/" target="_blank"><img class="aligncenter size-full wp-image-54" title="typebased" src="http://blog.sohaibmuneer.com/wp-content/uploads/2009/04/typebased.png" alt="typebased" width="424" height="320" /></a></p>
<p><a href="http://technorati.com/claim/kg8ag7i33f" rel="me">Technorati Profile</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sohaibmuneer.com/free-wordpress-themes-by-woothemes/feed</wfw:commentRss>
		<feedburner:origLink>http://blog.sohaibmuneer.com/free-wordpress-themes-by-woothemes</feedburner:origLink></item>
		<item>
		<title>Wall Street And Auto Industry by Calvin &amp; Hobbs</title>
		<link>http://feedproxy.google.com/~r/SohaibsBlog-CakePHPBaker/~3/3jaIJgLEkB0/wall-street-and-auto-industry-by-calvin-hobbs</link>
		<comments>http://blog.sohaibmuneer.com/wall-street-and-auto-industry-by-calvin-hobbs#comments</comments>
		<pubDate>Mon, 02 Feb 2009 23:46:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[yelly pad]]></category>

		<category><![CDATA[auto-industry]]></category>

		<category><![CDATA[calvin-and-hobb]]></category>

		<category><![CDATA[humor]]></category>

		<category><![CDATA[wall-street]]></category>

		<guid isPermaLink="false">http://blog.sohaibmuneer.com/?p=36</guid>
		<description><![CDATA[So I received an email from a friend explaining the plight of Wall street and the auto industry in a nutshell by Calvin and Hobbs. And this was published about 15 years ago !

]]></description>
			<content:encoded><![CDATA[<p>So I received an email from a friend explaining the plight of Wall street and the auto industry in a nutshell by Calvin and Hobbs. And this was published about 15 years ago !</p>
<div style="text-align: center;"><a class="aligncenter" href="http://blog.sohaibmuneer.com/wp-content/uploads/2009/02/calvin-n-hobbs.jpg" target="_blank"><img class="aligncenter size-medium wp-image-37" title="calvin-n-hobbs" src="http://blog.sohaibmuneer.com/wp-content/uploads/2009/02/calvin-n-hobbs-300x209.jpg" alt="calvin-n-hobbs" width="300" height="209" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.sohaibmuneer.com/wall-street-and-auto-industry-by-calvin-hobbs/feed</wfw:commentRss>
		<feedburner:origLink>http://blog.sohaibmuneer.com/wall-street-and-auto-industry-by-calvin-hobbs</feedburner:origLink></item>
		<item>
		<title>Why Avoid The “else” Construct ?</title>
		<link>http://feedproxy.google.com/~r/SohaibsBlog-CakePHPBaker/~3/1Au0vokxznI/why-avoid-the-else-construct</link>
		<comments>http://blog.sohaibmuneer.com/why-avoid-the-else-construct#comments</comments>
		<pubDate>Sat, 27 Dec 2008 14:56:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[construct]]></category>

		<category><![CDATA[if-else]]></category>

		<guid isPermaLink="false">http://blog.sohaibmuneer.com/?p=35</guid>
		<description><![CDATA[Till now I have seen a fair amount of code, the good, the bad and o yes! the ugly and the really really ugly. Ok, so you are a programmer, what makes you think a chunk of code is "good" or "bad" ? - I haven't had the opportunity to discuss this with fellow programmers [...]]]></description>
			<content:encoded><![CDATA[<p>Till now I have seen a fair amount of code, the good, the bad and o yes! the ugly and the really really ugly. Ok, so you are a programmer, what makes you think a chunk of code is "good" or "bad" ? - I haven't had the opportunity to discuss this with fellow programmers in detail, so I think the best way to air this would be to document this.</p>
<p>First thing that comes to my mind about good code is READABILITY ... it's imperative the code should be readable and understandable. This however, is automatically achieved when you follow the most optimum way of execution and is even prettier in OOP. Structured code provokes ugliness. And I have noticed that the code gets uglier when there are more and more if-elseif-else construct nesting. I have seen programmers abusing this construct a lot ! You are better off using a SWITCH-CASE construct (which should also be used if and only if necessary).</p>
<p>I know you must be thinking: So what's up with the "else" construct ? and what does this guy have against it ? - Well, in all honesty, I don't have anything against it. It's just that the "else" construct refrains me to write beatiful code <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> - Ask yourself, why would you need a lot of else statements anyways ? (do keep in mind that for menu choices you always have the good 'ol switch-case). This may not hold true when you are executing via the structured approach. When using OOP, it just doesn't make much sense. Of course, a simple "if-else" is ok as its simple and readable too. But when you are dwelling into if-elseif { if - else }-else { if - else } it becomes more complex and consequently turns into a nightmare. Imagine yourself trying to debug a 100 lines of code out which at least 40 are consumed by the nested "if" construct. Hehe, I know ! - It scares me too <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So what does it mean when you have used nested "if-elseif-else" structure a one too many times ? I answer this based on my own code more than a year ago. It means:</p>
<p>1. You are not breaking down problems into smaller chunks, that's for sure! - consequently you have become that greedy Ostrich who swallowed the whole freshly baked potato! so obviously the aftermath is the same. You jump, cry and get frustrated when you need to refactor the code or even worst, debug it.</p>
<p>2. Poor design ! - Yes ! poor design ! I don't care if you agree with me here or not, but you don't have a robust and scalable design before you put your cowboy hat on and went riding that keyboard. You did not think twice before coding. The rationale goes like this: An "if-else" construct denotes a change in variables and you address that change by changing the execution flow. Making the right decisions when a change occurrs. In an OO way, that variable change denotes a "state" change. So you do what you should according to that particular state. Similar to your reactions based on your emotional state,</p>
<p>Happy =&gt; Smile || Laugh</p>
<p>, Angry =&gt; Frown || Break something || Punch someone</p>
<p>, Sad =&gt; Cry || Whiskey++</p>
<p>In OO you can actually encapsulate execution as behaviors according to the change in state. As a result, you design is robust and scalable. All you need to do is invoke the right behavior for the right state. For that you'd probably need a simple IF statement.</p>
<p>3. Obviously either you haven't heard or you aren't interested in the philosophy behind "<a href="http://debuggable.com/posts/programming-psychology-return-home-early:4811de9f-ae28-49c2-a7dc-2f154834cda3" target="_blank">return home early</a>" - a term coined by Felix from debuggable.com - READ IT as it addresses programming psychology you might make use of.</p>
<p>Doh ! I've run out of time. I'm going to try to put some code slides up. You look at the code and decide for youself.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sohaibmuneer.com/why-avoid-the-else-construct/feed</wfw:commentRss>
		<feedburner:origLink>http://blog.sohaibmuneer.com/why-avoid-the-else-construct</feedburner:origLink></item>
		<item>
		<title>The Grunts And Groans Of Working From Home</title>
		<link>http://feedproxy.google.com/~r/SohaibsBlog-CakePHPBaker/~3/QxOZIe2wblU/the-grunts-and-groans-of-working-from-home</link>
		<comments>http://blog.sohaibmuneer.com/the-grunts-and-groans-of-working-from-home#comments</comments>
		<pubDate>Tue, 23 Dec 2008 07:26:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Life]]></category>

		<category><![CDATA[yelly pad]]></category>

		<category><![CDATA[work from home]]></category>

		<guid isPermaLink="false">http://blog.sohaibmuneer.com/?p=34</guid>
		<description><![CDATA[Before starting with me grunts and groans here’s a little note:
To all those who don't have experience of “working from home” try to turn off your judgments while you read. It's a classic example of “you don't know how it's like”. And those who fancy this way of doing business well guess what? you still [...]]]></description>
			<content:encoded><![CDATA[<p>Before starting with me grunts and groans here’s a little note:</p>
<blockquote><p>To all those who don't have experience of “working from home” try to turn off your judgments while you read. It's a classic example of “you don't know how it's like”. And those who fancy this way of doing business well guess what? you still don’t get to be a slacker.</p></blockquote>
<p>First off, being human, we have to socialize in some way. For most of us, just having 100+ friends on facebook or any other social network is appealing, but not the real thing. Socializing becomes a challenge when working from home amidst many others. This is the biggest challenge what I have experienced so far, and overcame it too (this part would require a separate post :P). Thank god I don't work alone now. But still, one could rot if one does not step out of the house so very often. To counter this, surely you’d socialize on all those social networks out there, but to get the real thing, here is what I had found useful:</p>
<ul>
<li><strong>-</strong> Spend some good 30 minutes outside (and this is for the worst of the introverts out there, it should be an hour or so – no offence). Take a stroll in a park / peaceful place or join a gym. Some fresh air won’t kill ya! But staying inside surrounded by 4 walls will definitely do some damage to your brain.</li>
<li><strong>-</strong> Try to network up with people who are in the same line of business as you are. And meet up!</li>
<li><strong>-</strong> Keep an eye out for different events happening out there that are even mildly related to your industry. Try to show up on those. Trust me you’ll feel great when you meet the alike. And probably the best way to do that would be to join a local community.  Finally! You might be able to put all those social networking apps to the right use <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> – I’m sure you’d be able to find your local user group through these networks.</li>
</ul>
<p>Apart of the social issue, here comes another. People don’t tend to take you seriously when you tell them you work from home. This can be frustrating at times. People are still getting used to the idea and some just reject it. This is especially true for countries like Pakistan and I’m sure India’s in the list too. Like many other countries, we both have a family oriented environment and mostly I find people “branding” themselves based on the companies they work in a one too many times. So after having a couple of these experiences, the idea came like a lightning bolt! Yup ! get yourself a business card!, just shrink the “what you do part” in a single understandable phrase. For instance, I use “Software Engineer” that works for me. The funny part is, I’ve experienced that people don’t really understand the “software” part <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> they just calm down when they hear “engineer”, which is actually really cool as I’m always giggling when witnessing this. Ah! On the other hand, this always makes me wonder when the hell we are going to get out of this entire stereo-typical behavioral pattern.<br />
The third evil is keeping loose work timings. This can be cancerous to your work! – seriously! Some people may not realize this until after they find themselves in the middle of a crisis. And I had to find this the hard way … doh ! You have to separate your work timings. Sure sure, you must be thinking I didn’t choose to work from home just so that I work strict timings. Unfortunately, to keep professionalism, discipline is important. Can’t say this for sure about designers and the more creative kind but I can say this certainly for programmers. Although, you might be one of those <a href="http://blog.sohaibmuneer.com/striving-to-become-a-better-code-jockey" target="_blank">people who are most creative during specific times</a> of day, then you should time yourself according to that. You see this is where working from home comes in handy. You can choose your own timings.<br />
A few things can help you achieve discipline. You can start off by creating a separate email, IM and phone for your work. It’d be easier to discipline your work this way. Although here I would have to admit that I haven’t been able to implement that yet, but keeping in view my plans, I might not need to. Trust me, it’s really important to keep your private and work contacts separate. The next thing you’d know is that your private email is bombarded by client requests and your private phone is ringing so very often with clients on other end and your folks giving you strange looks.<br />
In essence, the important thing is that you should find time and reflect on other important aspects of your life during the day. I think I know now why there is an 8 hour per day work limit. It helps strike a balance between your private and work life. Honestly, when you are working from home you can cross that work limit very easily without even knowing what you did till later. But there are always exceptions. People who are passionate about something won’t stop at nothing till they achieve it. If you’re not that obsessive about something, then you should strike a balance with discipline.<br />
I’m sure my experiences are quite similar with other people. Let me know if there are any differences you find. That would surely help me understand this better <img src='http://blog.sohaibmuneer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sohaibmuneer.com/the-grunts-and-groans-of-working-from-home/feed</wfw:commentRss>
		<feedburner:origLink>http://blog.sohaibmuneer.com/the-grunts-and-groans-of-working-from-home</feedburner:origLink></item>
	</channel>
</rss>

