<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Emran Hasan&#039;s Blog &#187; RBS</title>
	<atom:link href="http://phpfour.com/blog/category/rbs/feed/" rel="self" type="application/rss+xml" />
	<link>http://phpfour.com/blog</link>
	<description>The everyday sharing of Emran Hasan on software development.</description>
	<lastBuildDate>Fri, 20 Jan 2012 11:39:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Setting up central Mercurial server in Ubuntu</title>
		<link>http://phpfour.com/blog/2011/05/setting-up-central-mercurial-server-in-ubuntu/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=setting-up-central-mercurial-server-in-ubuntu</link>
		<comments>http://phpfour.com/blog/2011/05/setting-up-central-mercurial-server-in-ubuntu/#comments</comments>
		<pubDate>Sat, 07 May 2011 20:33:32 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[RBS]]></category>
		<category><![CDATA[dev process]]></category>
		<category><![CDATA[dev team]]></category>
		<category><![CDATA[dvcs]]></category>
		<category><![CDATA[mercurial]]></category>

		<guid isPermaLink="false">http://phpfour.com/blog/?p=342</guid>
		<description><![CDATA[It&#8217;s been a while since we&#8217;ve been thinking about moving to Mercurial from Subversion at our company. We were convinced about the benefits of DVCS and chose Mercurial over Git. However, due to pressure at work and some procrastination, the move was delayed a couple times. Finally, today we had the move and the team [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://mercurial.selenic.com/"><img class="alignleft" title="Mercurial" src="http://mercurial.selenic.com/images/mercurial-logo.png" alt="Mercurial" width="184" height="61" /></a></p>
<p>It&#8217;s been a while since we&#8217;ve been thinking about moving to Mercurial from Subversion at our <a href="http://www.rightbrainsolution.com">company</a>. We were convinced about the benefits of DVCS and chose Mercurial over Git. However, due to pressure at work and some procrastination, the move was delayed a couple times. Finally, today we had the move and the team is already up to speed with it.</p>
<p>Although it&#8217;s quite simple to install it in a central server, the different articles on the web had me confused with too many options or with a different distro than Ubuntu. So, here is a dead simple list of things to do for installing Mercurial centrally for your dev team.</p>
<p><span id="more-342"></span><br />
1. Log onto your server using SSH</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">ssh</span> admin<span style="color: #000000; font-weight: bold;">@</span>rbs-server.com</div></div>
<p>2. Install mercurial from repository:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get update</span><br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> mercurial</div></div>
<p>3. We need to have a directory to store our Mercurial configuration and repository files, so let&#8217;s create one and change it&#8217;s owner to the apache user so that apache can access them:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span><br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> hg<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> hg<span style="color: #000000; font-weight: bold;">/</span>repos<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> www-data:www-data hg<span style="color: #000000; font-weight: bold;">/</span>repos</div></div>
<p>4. We&#8217;ll be creating a configuration that will allow us to host multiple repositories in this server. And we&#8217;ll be using CGI to serve the files through Apache:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>hg<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>doc<span style="color: #000000; font-weight: bold;">/</span>mercurial<span style="color: #000000; font-weight: bold;">/</span>examples<span style="color: #000000; font-weight: bold;">/</span>hgweb.cgi .<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> a+x hgweb.cgi</div></div>
<p>5. We need to show the location of the config file to the CGI script, so open the file <strong>hgweb.cgi</strong> with nano or vim to update the line with &#8220;config = &#8230;&#8221; with the following and save it.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">config = &quot;/var/hg/hgweb.config&quot;</div></div>
<p>6. Now let&#8217;s create the file <strong>/var/hg/hgweb.config</strong> and write the location of the repositories:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> hgweb.config</div></div>
<p>Enter the following content and save the file:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[collections]<br />
/var/hg/repos = /var/hg/repos</div></div>
<p>7. As a final step, we&#8217;ll need to update the Apache configuration so that it executes the CGI when requested with a <strong>/hg</strong> prefix:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>sites-available<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> default</div></div>
<p>At the end of the defaul virtual host configuration and just before the &lt;/VirtualHost&gt; tag, add the following and save it:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ScriptAlias /hg &quot;/var/hg/hgweb.cgi&quot;<br />
<br />
AuthType Basic<br />
AuthName &quot;Mercurial repositories&quot;<br />
AuthUserFile /var/hg/hgusers<br />
Require valid-user</div></div>
<p>8. In order to take effect of the above change, we&#8217;ll need to restart apache:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apache2ctl restart</span></div></div>
<p>9. Now you should be able to visit the server&#8217;s /hg location like <strong>http://rbs-server.com/hg</strong> from browser. However, you&#8217;ll be greeted with a username/password prompt as we&#8217;ve enabled that in our apache configuration above. So, lets add some user for our use.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>hg<br />
htpasswd <span style="color: #660033;">-mc</span> hgusers admin</div></div>
<p>It will ask for the password of the user admin twice and after you enter that, it will be stored in the file <strong>hgusers</strong>. You can add more users in the similar fashion, just ignore the <strong>c</strong> parameter as it was used to create the file first time:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">htpasswd <span style="color: #660033;">-m</span> hgusers abid<br />
htpasswd <span style="color: #660033;">-m</span> hgusers saeed<br />
...</div></div>
<p>10. Now visit the /hg path in your browser and you&#8217;ll see the empty list of repositories after you authenticate.</p>
<p>11. By default Mercurial only allows pushing changes through SSL, but in our case it was not necessary. Also, we wanted to give all our developers the push access to the repositories. For that, let&#8217;s update the system-wide mercurial configuration file <strong>/etc/mercurial/hgrc</strong> by adding the following lines at the end of the file and saving it:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[web]<br />
allow_push = *<br />
push_ssl = false</div></div>
<p>12. Now that all is set, let&#8217;s setup a test repository so that we can clone it in our development machine:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>hg<span style="color: #000000; font-weight: bold;">/</span>repos<br />
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #7a0874; font-weight: bold;">test</span><br />
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #7a0874; font-weight: bold;">test</span><br />
hg init</div></div>
<p>This repository can now be accessed through <strong>http://rbs-server.com/hg/test</strong> and can be cloned in a development machine with the following command (mercurial must be installed already):</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<br />
hg clone http:<span style="color: #000000; font-weight: bold;">//</span>rbs-server.com<span style="color: #000000; font-weight: bold;">/</span>hg<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">test</span></div></div>
<p>Hope this will make someone&#8217;s life easy. Enjoy the beauty of Mercurial!</p>
<p><a href="http://www.flickr.com/photos/burnblue/109530851/" target="_blank">Photo source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2011/05/setting-up-central-mercurial-server-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>phpXperts &#8217;09 seminar</title>
		<link>http://phpfour.com/blog/2009/05/phpxperts-09-seminar-becoming-a-php-ninja/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=phpxperts-09-seminar-becoming-a-php-ninja</link>
		<comments>http://phpfour.com/blog/2009/05/phpxperts-09-seminar-becoming-a-php-ninja/#comments</comments>
		<pubDate>Sun, 17 May 2009 12:29:25 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[RBS]]></category>
		<category><![CDATA[Talks]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[efficiency]]></category>
		<category><![CDATA[phpxperts]]></category>
		<category><![CDATA[seminar]]></category>
		<category><![CDATA[speech]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=243</guid>
		<description><![CDATA[At last the phpXperts seminar on &#8220;Current Web Trends&#8221; have taken place and I was one of the speakers there. Among all the topics, mine was a bit suggestive and naturally a bit less exciting. I spoke about how to become a PHP ninja &#8211; what are the characteristics they posses, what are the tools [...]]]></description>
			<content:encoded><![CDATA[<p>At last the phpXperts seminar on &#8220;Current Web Trends&#8221; have taken place and I was one of the speakers there. Among all the topics, mine was a bit suggestive and naturally a bit less exciting. I spoke about how to become a PHP ninja &#8211; what are the characteristics they posses, what are the tools they use, what are the paths they follow etc. It&#8217;s actually a follow-up of one of my blog posts: &#8220;<a href="http://www.phpfour.com/blog/2008/10/become-kick-ass-php-ninja-from-newbie-guide-tips/">Becoming a kick-ass PHP ninja</a>&#8220;.</p>
<p>Here goes the slides:</p>
<div id="__ss_1448402" style="margin: 0pt auto; width: 425px; text-align: center;"><object width="425" height="355" data="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=becomingaphpninja-090517141544-phpapp01&amp;stripped_title=becoming-a-php-ninja" type="application/x-shockwave-flash"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=becomingaphpninja-090517141544-phpapp01&amp;stripped_title=becoming-a-php-ninja" /><param name="allowfullscreen" value="true" /></object></div>
<p>All the other slides, pictures, and videos are available <a href="http://slides.phpxperts.net/">here</a>.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2009/05/phpxperts-09-seminar-becoming-a-php-ninja/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Becoming a Kick-ass PHP ninja</title>
		<link>http://phpfour.com/blog/2008/10/become-kick-ass-php-ninja-from-newbie-guide-tips/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=become-kick-ass-php-ninja-from-newbie-guide-tips</link>
		<comments>http://phpfour.com/blog/2008/10/become-kick-ass-php-ninja-from-newbie-guide-tips/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 03:35:53 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[RBS]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[employment]]></category>
		<category><![CDATA[essential]]></category>
		<category><![CDATA[Gadgets]]></category>
		<category><![CDATA[guideline]]></category>
		<category><![CDATA[inspiration]]></category>
		<category><![CDATA[kick-ass]]></category>
		<category><![CDATA[php ninja]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=106</guid>
		<description><![CDATA[Who is this for? You&#8217;ve been developing web applications using PHP for a couple months now and are finding it very enjoyable. Although you feel that you&#8217;re doing quite good, you&#8217;re not sure whether its the end. Besides, the following questions wonder you often: Where to go from here What new things to learn How [...]]]></description>
			<content:encoded><![CDATA[<h3>Who is this for?</h3>
<p>You&#8217;ve been developing web applications using PHP for a couple months now and are finding it very enjoyable. Although you feel that you&#8217;re doing quite good, you&#8217;re not sure whether its the end. Besides, the following questions wonder you often:</p>
<ul>
<li>Where to go from here</li>
<li>What new things to learn</li>
<li>How to become a Kick-ass PHP Ninja</li>
</ul>
<p>If that&#8217;s the scenario, then this post if for <strong>YOU</strong>.</p>
<h3>Background</h3>
<p>A few days back, I read a number of blog <a href="http://inter-sections.net/2007/11/13/how-to-recognise-a-good-programmer">posts</a> where people have highlighted the <a href="http://hasin.wordpress.com/2008/04/30/signs-you-are-ruining-your-career-as-a-web-app-developer/">shortcomings</a> they see in newbie developers. Some of them have gone further to narrow down the focus on <a href="http://www.boringguys.com/2008/05/20/beware-the-lone-wolf-php-developer/">PHP developers only</a> (as PHP&#8217;s nature sometimes allow developers to avoid standards). They did a great job by listing the shortcomings, but their posts missed clear way forwards (these can be inferred though). A number of readers also commented on the posts with their insight as well. So I was thinking how about compiling all these in an easy to follow list? Hence this post.</p>
<p>Btw, due to the volume, I&#8217;ve mostly touched the points here and provided few useful resource links for further study. I do have plan to elaborate a few of them in coming posts, with each point becoming a single post. Let me know which ones you&#8217;ll prefer most, by entering the poll at the bottom of the post.</p>
<h3>Part A : Technical Way Forward</h3>
<p>In the first part, let&#8217;s shed some light on how you can move forward with your technical abilities.</p>
<p><strong>1. Start using version control</strong></p>
<p>Version control is like a big UNDO button for your coding. You can go back to your previous code revisions and can compare/rollback to specific code areas anytime you see necessary. It will keep track of all your changes and will empower you to track your development changes across your work/team. Also, in a distributed development team, version control helps prevent overwriting of code by team members and keeps all the members code up to date.</p>
<p><a href="http://subversion.tigris.org">Subversion (SVN)</a> is one of the most popular open source version control system. If you&#8217;re on windows platform, you can try <a href="http://tortoisesvn.net">TortoiseSVN</a>, a client for SVN.</p>
<p><strong>2. Write code in OOP way</strong></p>
<p>If you haven&#8217;t already, it&#8217;s high time you started writing code in Object Oriented Programming (OOP) way. You may ask why? Well, OOP forces you to write code that is maintainable in nature. If properly followed, OOP code become a lot efficient than procedural code. Also, it allows you to re-use code across your project and/or multiple projects.</p>
<p>If you&#8217;re not convinced, have a <a href="http://www.phpdeveloper.org/news/5719">look</a> at <a href="http://www.php.net/oop">these</a> excellent <a href="http://www.killerphp.com/tutorials/object-oriented-php/">resources</a> for further study.</p>
<p><strong>3. Adhere to a coding standard</strong></p>
<p>Coding standards allow you to write code in a way which is easily understood by other people. When you adhere to a coding standard used by may others, you actually convey a message that you&#8217;re serious in writing code that people will be able to &#8220;get&#8221; and maintain. Keeping abbreviation type variable names, applying multiple indention types, writing meaningless function names etc will work for you in short term, maybe in personal projects. But when you move to a larger group with a number of developers, you ought to follow a standard so that everybody working with you can get along with your parts.</p>
<p>The following standards are most widely used among PHP developers around the globe:</p>
<ul>
<li><a href="http://pear.php.net/manual/en/standards.php">PEAR Coding Standards</a></li>
<li><a href="http://framework.zend.com/manual/en/coding-standard.html">Zend Framework Coding Standards</a></li>
<li><a href="http://ez.no/ezpublish/documentation/development/standards/php">eZ Publish PHP Coding Standards (depreciated)</a></li>
<li><a href="http://www.ezcomponents.org/contributing/coding_standards">eZ Components Implementation guidelines</a></li>
</ul>
<p>Although you can define a standard for your team/company, it&#8217;s always better to have close relation with what the industry follows. In my company, Right Brain Solution Ltd, we follow a slightly modified version of Zend Framework Coding Standards. You can get that one <a href="http://www.rightbrainsolution.com/php_coding_standard_rbs.pdf">here</a>.</p>
<p><strong>4. Document your code</strong></p>
<p>Documentation is a virtue of great developers &#8211; don&#8217;t get me wrong, I&#8217;m talking about code documentation, not writing user manuals <img src='http://phpfour.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Well documented code prevents other team members from reading each line of your code and understand them by heart. Rather, it tells them exactly what they need to know &#8211; purpose of the code, what it requires as input, what it will deliver as output, etc. If you take a look at the above mentioned coding standards, you&#8217;ll discover that most of them even specified standard for documentation as well, which is <a href="http://www.phpdoc.org/">phpDocumentor</a>. It&#8217;s the most used standard for PHP code documentation and is widely recognized.</p>
<p><strong>5. Use a good framework</strong></p>
<p>Frameworks give you good structure and helps you build web applications in a fast way, with confidence. Most of today&#8217;s popular PHP frameworks (<a href="http://framework.zend.com/">Zend Framework</a>, <a href="http://www.codeigniter.com/">CodeIgniter</a>, <a href="http://cakephp.org/">CakePHP</a>, <a href="http://www.symfony-project.org">Symfony</a>, <a href="http://kohanaphp.com">Kohana</a> etc) follow the Model-View-Controller (MVC) pattern, which itself is a strong advocate of good practice.</p>
<p>Besides structure, frameworks force you to write code in a structured way. Some of them will also require writing the code in OOP &#8211; whose benefit we already discussed above. And frameworks usually come with a number of helpful libraries and helpers, to make your life easy as a web developer.</p>
<p>Josh sharp discusses this in details <a href="http://joshsharp.com.au/blog/view/why_you_should_be_using_a_framework">here </a>and later posts a follow-up <a href="http://joshsharp.com.au/blog/view/perhaps_the_world_doesnt_need_another_framework">here</a>. Both are good reads.</p>
<p><strong>6. Re-use code/libraries</strong></p>
<p>One of the most common advice programmers get is: &#8220;Don&#8217;t re-invent the wheel&#8221;. Well, what&#8217;s the point here? It actually means that you should not spend much time on solving a problem that has already been solved, in efficient way, by others. Rather solving it out yourself, you can &#8220;google&#8221; it and see how others have done it. It will not only save your valuable time, but also will ensure stable code (assuming that people usually post things on web after doing a number of testing and user of the codes usually help iron-out any issues, etc).</p>
<p>However, keep an eye on your target use/objective. If there is not enough good solutions that solves your problem, go ahead and solve yourself. Make it good and give it back to the community so that others facing that problem won&#8217;t need to spent the time you&#8217;ve spent. The whole open source model runs on this give-give way, so be a part of it.</p>
<p><strong>7. Test your code the right way</strong></p>
<p>In order to make confidence out of your code, you&#8217;ll need to test your code the right way. Although you might be used to testing your application using debug messages and browser refreshes, in a real world scenario these won&#8217;t work. You&#8217;ll need to write unit tests which can do automated testing of your code. The power lies in that you can run these tests almost anytime and can check if anything is broken after each new change.</p>
<p><a href="http://www.phpunit.de/">PHPUnit</a> and <a href="http://www.simpletest.org/">SimpleTest</a> are the two most widely used Unit testing suite for PHP. You should also have a look on <a href="http://en.wikipedia.org/wiki/Test-driven_development">Test Driven Development (TDD)</a>, which is the way of greatly enhancing your chance of deploying application with least bugs.</p>
<h3>Part B : Personal Way Forward</h3>
<p>Now, even if you&#8217;ve improved yourself on the above mentioned points, you&#8217;ll still need to work on your personal matters to move forward. Here goes those points.</p>
<p><strong>8. Be Agile</strong></p>
<p>You need to be an agile developer if you want to move forward in your career. What does it mean to be agile? Agility is more of an attitude than a skill set. The common characteristics of agile developers are:</p>
<ul>
<li>They’re open minded and therefore willing to learn new techniques</li>
<li>They’re responsible and therefore willing to seek the help of the right person(s) for the task at hand</li>
<li>They&#8217;re willing to work closely with others, pair programming or working in small teams as appropriate</li>
<li>They&#8217;re willing to work iteratively and incrementally</li>
</ul>
<p>Further resources: <a href="http://en.wikipedia.org/wiki/Agile_software_development">Agile Software Development</a>, <a href="http://agilemanifesto.org/">The Agile Manifesto</a>.</p>
<p><strong>9. Keep yourself updated</strong></p>
<p>No matter what, keep yourself updated on whats going on in your field (in this case PHP). Subscribe to the RSS of great PHP blogs and skim over them on a regular basis. Dig into the topics that interest you most and see the author&#8217;s point. Also, keep a habit of trying new technologies every now &#038; then. It gives you an edge over others and when any discussion goes about it, you can help others understand as well as make your points.</p>
<p>Btw, if you don&#8217;t have a clue where to find good blogs, have a look at <a href="http://planet-php.org/">here</a>, <a href="http://hasin.wordpress.com/2007/07/12/list-of-rss-feeds-i-read-almost-everyday/">here</a> and <a href="http://godbit.com/article/reading-list">here</a>.</p>
<p><strong>10. Start community involvement</strong></p>
<p>Remember I told above to give your work back to the community ? How to do that ? <a href="http://wordpress.com/">Start a blog</a> of your own and start writing posts there every now &#038; then. Yes, I know you&#8217;d say &#8220;Who&#8217;s going to read my blog anyway?&#8221;, but if you share your experience, someday, somebody will find it useful. And if you can share things that others haven&#8217;t done, you&#8217;ll slowly see visitors coming on your blog increasing way.</p>
<p>Besides blog, try to participate in tech <a href="http://www.sitepoint.com/forums/">forums</a> and <a href="http://tech.groups.yahoo.com/group/phpexperts">communities</a>. Help people out in the areas you excel and at the time of your need, other people will be happy to help you out as well. These communities are also great place to learn about many unusual matters, see how situation changes from person to person, place to place, etc. You&#8217;ll also be able to make great friends who might come handy later in your life.</p>
<p>Another great way of community involvement is to contributing to <a href="https://www.ohloh.net/projects">open source projects</a>. Share some of your valuable time for an open source project and it may come handy for a huge number of people. Your work might solve the problem of somebody like you. If needed, <a href="http://www.orchidframework.com/">initiate</a> an open source project yourself and invite others to work on your vision.</p>
<p><strong>11. Use a good IDE</strong></p>
<p>With due respect to <a href="http://www.adobe.com/products/dreamweaver/">Dreamweaver</a>, step forward and use an IDE made for PHP. You&#8217;ll notice the difference in a few days when you&#8217;ll see that your productivity has increased in great ways. These IDEs provide great number of useful features including but not limited to: syntax highlighting, auto completion, code suggestions, code snippets, contextual help, code templates, debugging, profiling, etc.</p>
<p>The following IDEs mostly have the similar feature set and can boost your productivity in great ways:</p>
<ul>
<li><a href="http://www.nusphere.com/products/phped.htm">NuSphere PhpED</a></li>
<li><a href="http://www.mpsoftware.dk/">phpDesigner 2008</a></li>
<li><a href="http://www.zend.com/en/products/studio/">Zend Studio for Eclipse</a></li>
</ul>
<p>Personally I use <strong>NuSphere PhpED 5.2</strong> and I love it in every way. They&#8217;ve provided me with a complementary license and I am grateful to them for that. If you&#8217;re planning to buy it, let me know and I might find you a discount.</p>
<p><strong>12. Be communicative</strong></p>
<p>In your team/company, try to be as communicative as possible. It reduces a lot of confusions, makes you close to other devs so that you understand them, portrays you as a good person in front of management and overall, helps you enjoy your work. When you&#8217;re working together with others, make them feel that you&#8217;re there and ready to give whatever it takes. Create a personal brand of yourself.</p>
<h3>What&#8217;s next?</h3>
<p>Phew! It&#8217;s quite a good amount of writing in a while <img src='http://phpfour.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I&#8217;ve tried to cover most of the items I found to be important. However, there might be some points I&#8217;ve overlooked so feel free to post them in the comments. If this helps any one of the developers I intend it for, then I&#8217;ll take that the effort is successful.</p>
<p>Thanks everybody, Happy Eid Mubarak to you!</p>
<div style="background-color: #EAF3FA;border: 1px solid #464646;">[poll id="3"]</div>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2008/10/become-kick-ass-php-ninja-from-newbie-guide-tips/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>Beware of the so called &quot;Senior PHP Developers&quot;</title>
		<link>http://phpfour.com/blog/2008/08/beware-of-so-called-senior-php-developers/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=beware-of-so-called-senior-php-developers</link>
		<comments>http://phpfour.com/blog/2008/08/beware-of-so-called-senior-php-developers/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 08:16:34 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[RBS]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[employment]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[job]]></category>
		<category><![CDATA[senior]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=108</guid>
		<description><![CDATA[With the rise of PHP developer as career, many are trying to get their share in the pie. Lately I&#8217;ve met a number of developers who have worked for more than one/two years in developing PHP applications in various companies and they consider themselves as &#8220;senior&#8221; developers. They try to emphasize that they&#8217;ve done enough [...]]]></description>
			<content:encoded><![CDATA[<p>With the rise of <a href="http://www.boringguys.com/2008/05/13/php-developer-jobs-are-the-hottest-ever/">PHP developer as career</a>, many are trying to get their share in the pie. Lately I&#8217;ve met a number of developers who have worked for more than one/two years in developing PHP applications in various companies and they consider themselves as &#8220;senior&#8221; developers. They try to emphasize that they&#8217;ve done enough raw programming and they are now in a position where they&#8217;ll only design architecture of applications.</p>
<p>When you interview them and ask about complex topics, they&#8217;ll reply: &#8220;<strong>Oh my last company didn&#8217;t allow me work with that, but I&#8217;ll be able to grab that in a day</strong>&#8220;. You trust them and think that if they get the chance, they&#8217;ll sure be able to excel. After all, they&#8217;ve got that Company X&#8217;s experience and Guru Y&#8217;s reference.<br />
<span id="more-108"></span><br />
At first everybody gets amazed with these developers employment history, the projects they&#8217;ve done, the technical jargons they can utter, the ideology/framework/pattern they talk about, etc etc. Everybody wants them in their team. The team who gets them finally are happier than ever, after all life will get easier to have such an expert in team.</p>
<p>Soon projects get rolling and everybody in his/her team is eagerly waiting to see the magics from these &#8220;senior&#8221; developers. To their disappointment, more ideas/criticism/review (e.g. &#8220;<em><strong>Pattern X is better than pattern Y. Why you&#8217;re choosing X?&#8221;, &#8220;Why are you doing Z in this way? Who taught you this?&#8221;, &#8220;Have you ever heard of DEF?&#8221;, &#8220;I have done research on DB normalization and you teach me schema?</strong></em>&#8220;) takes place but they don&#8217;t see actual code from these developers.</p>
<p>They come to office in an awkward timing, leaves early, works with personal things at office &#8211; but nobody can question their activity as people might not believe them. With much regret, the remaining team members continue to complete the work which the &#8220;senior&#8221; developer was suppose to do. Instead of a team <strong>synergy</strong>, an unintended <strong>pressure</strong> is created in the team.</p>
<p>Eventually the project misses deadline by miles, team members become unhappy as they had to do extra work each day to cover the team&#8217;s ass, company gets screwed as client is unhappy and decides not to do repeat business. Company digs down the cause of the failure, finds the responsible person, and fires them away.</p>
<p>Surprisingly, when a friend of the &#8220;senior&#8221; developer asks them in a social party: &#8220;What happened with the Company X you were working on?&#8221;, they&#8217;ll reply: &#8220;<em><strong>Oh that crap! You know, it&#8217;s a pain to work with junior developers. They don&#8217;t understand things. All they know is coding, no knowledge, no understanding of architecture. And the management is so poor, you won&#8217;t believe&#8230;&#8230;</strong></em>&#8220;.</p>
<p>Don&#8217;t include someone like them in your team and think twice or thrice if you don&#8217;t have many options. Try to find out how <a href="http://inter-sections.net/2007/11/13/how-to-recognise-a-good-programmer">good programmer</a> they are in the interview. How senior they might be, ask them to write code in the interview. Try out <a href="http://smallbusiness.logoworks.com/newsletter/index.php/03/2007/02/14-killer-questions-to-ask-in-your-next-interview/?intsrc=n4.2&#038;lpn=Newsletter%20Landing">proven questions</a> that others have shared from their experience. Overall, make sure you&#8217;re taking the right person. The best hiring option is to hire &#8220;no one&#8221;.</p>
<p>Have you been in such situation? Share your experience here!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2008/08/beware-of-so-called-senior-php-developers/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Extended Model for CodeIgniter</title>
		<link>http://phpfour.com/blog/2008/07/extended-model-for-codeigniter/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=extended-model-for-codeigniter</link>
		<comments>http://phpfour.com/blog/2008/07/extended-model-for-codeigniter/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 20:59:03 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[RBS]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[Code Igniter]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/?p=104</guid>
		<description><![CDATA[Feb 2009: An updated version of the code for CodeIgniter 1.7.x can be found here. I developed this extension of CodeIgniter&#8217;s Model last year, but never had the chance to publish it. The main purpose of this extension is to make a dev&#8217;s life easy. This extension has been used by several of my devs [...]]]></description>
			<content:encoded><![CDATA[<blockquote class="left"><p><strong>Feb 2009: An updated version of the code for CodeIgniter 1.7.x can be found</strong> <a href="http://www.phpfour.com/blog/2009/02/updated-http-class-extended-model-codeigniter-cross-domain-ajax-php/">here</a>.
</p></blockquote>
<p>I developed this extension of CodeIgniter&#8217;s Model last year, but never had the chance to publish it. The main purpose of this extension is to make a dev&#8217;s life easy. This extension has been used by several of my devs at <a target="_blank" href="http://www.rightbrainsolution.com" title="Download Model">RBS</a> and has been proved to increase productivity and reduce the number of painful small queries to write. Their enthusiasm has driven me to post this for the CI fans out there.</p>
<p>Without much babble, let&#8217;s get into point. I&#8217;ve explained the process of installing it and then showed some example uses. For starter, click <a target="_blank" href="http://www.phpfour.com/blog/downloads/model-ci" title="Download Model">here</a> to download it. Now follow these steps to get started:</p>
<p><span id="more-104"></span></p>
<p>1. Replace the system/libraries/Model.php file with the attached Model.php (CodeIgniter version 1.6.3)</p>
<p>2. For each of your tables, you will need to create a model file in system/application/models. </p>
<p>3. Lets say we have a &quot;products&quot; table whose schema is as follows:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">TABLE</span> `products` (</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>       `id` <span style="color: #0000ff">int</span>(11) <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span> auto_increment,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>       `title` <span style="color: #0000ff">varchar</span>(50) <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>       `description` text <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>       `color` <span style="color: #0000ff">varchar</span>(20) <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>       `price` <span style="color: #0000ff">float</span> <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>       `category_id` <span style="color: #0000ff">int</span>(11) <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>       `featured` <span style="color: #0000ff">char</span>(1) <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>       `enabled` <span style="color: #0000ff">char</span>(1) <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>       `visits` <span style="color: #0000ff">int</span>(1) <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>       `created` <span style="color: #0000ff">int</span>(11) <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>       `modified` <span style="color: #0000ff">int</span>(11) <span style="color: #0000ff">NOT</span> <span style="color: #0000ff">NULL</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>       <span style="color: #0000ff">PRIMARY</span> <span style="color: #0000ff">KEY</span>  (`id`)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>     ) ENGINE=MyISAM;</pre>
</p></div>
</div>
<p>4. Now we need to create system/application/models/product.php:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> &lt;?php  <span style="color: #0000ff">if</span> (!defined(<span style="color: #006080">'BASEPATH'</span>)) exit(<span style="color: #006080">'No direct script access allowed'</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     <span style="color: #0000ff">class</span> Product extends Model {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>         function Product()</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>         {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>             <span style="color: #008000">// Call the Model constructor</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>             parent::Model();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>             </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>             <span style="color: #008000">// Load the associated table</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>             $<span style="color: #0000ff">this</span>-&gt;loadTable(<span style="color: #006080">'products'</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>         }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>     }</pre>
</p></div>
</div>
<p>5. From any controller, you can load the Model as instructed in the CI manual. Here are some sample usage of the model functions:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> function products()</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>     {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>         <span style="color: #008000">// Load the model in the default way</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>         $<span style="color: #0000ff">this</span>-&gt;load-&gt;model(<span style="color: #006080">'Product'</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>         <span style="color: #008000">// Total # of products</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>         echo $<span style="color: #0000ff">this</span>-&gt;Product-&gt;findCount();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>         <span style="color: #008000">// Total # of featured products</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>         echo $<span style="color: #0000ff">this</span>-&gt;Product-&gt;findCount(<span style="color: #006080">&quot;featured = 'Y'&quot;</span>); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>         <span style="color: #008000">// Retrieve ALL the products</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>         $allProducts = $<span style="color: #0000ff">this</span>-&gt;Product-&gt;findAll(); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>         <span style="color: #008000">// Retrive id, title and price of top 10 products (based on popularity) that are enabled</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>         $topProducts = $<span style="color: #0000ff">this</span>-&gt;Product-&gt;findAll(<span style="color: #006080">&quot;enabled = 'Y'&quot;</span>, <span style="color: #006080">'id, title, price'</span>, <span style="color: #006080">'visits DESC'</span>, <span style="color: #006080">'0'</span>, <span style="color: #006080">'10'</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>         <span style="color: #008000">// Retrive id, title and price of the 1st most popular product that is enabled</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span>         $topProducts = $<span style="color: #0000ff">this</span>-&gt;Product-&gt;find(<span style="color: #006080">&quot;enabled = 'Y'&quot;</span>, <span style="color: #006080">'id, title, price'</span>, <span style="color: #006080">'visits DESC'</span>, <span style="color: #006080">'0'</span>, <span style="color: #006080">'10'</span>); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span>         <span style="color: #008000">// Retrieve the product with id = 1</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span>         $oneProduct = $<span style="color: #0000ff">this</span>-&gt;Product-&gt;read(1); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  23:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  24:</span>         <span style="color: #008000">// Retrive the price of the product whose id = 1</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  25:</span>         $productPrice = $<span style="color: #0000ff">this</span>-&gt;Product-&gt;field(<span style="color: #006080">'price'</span>, <span style="color: #006080">'id = 1'</span>); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  26:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  27:</span>         <span style="color: #008000">// Single array with the titles of all the enabled products</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  28:</span>         $productArr = $<span style="color: #0000ff">this</span>-&gt;Product-&gt;generateSingleArray(<span style="color: #006080">&quot;enabled = 'Y'&quot;</span>, <span style="color: #006080">'title'</span>); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  29:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  30:</span>         <span style="color: #008000">// Insert a new product in the db</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  31:</span>         $newProductId = $<span style="color: #0000ff">this</span>-&gt;Product-&gt;insert(array(<span style="color: #006080">'title'</span> =&gt; <span style="color: #006080">'New Product'</span>, <span style="color: #006080">'price'</span> =&gt; <span style="color: #006080">'10.99'</span>)); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  32:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  33:</span>         <span style="color: #008000">// Update the price of the newly added product</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  34:</span>         $updProduct = $<span style="color: #0000ff">this</span>-&gt;Product-&gt;save(array(<span style="color: #006080">'price'</span> =&gt; <span style="color: #006080">'20.00'</span>), $newProductId); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  35:</span>         </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  36:</span>         <span style="color: #008000">// Delete the product</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  37:</span>         $<span style="color: #0000ff">this</span>-&gt;Product-&gt;remove($new_product_id);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  38:</span>     }</pre>
</p></div>
</div>
<p>7. There are a number of other helpful functions in this file. If you have a careful look, you&#8217;ll discover that some of them are really handy.</p>
<p>UPDATE: I forgot to give due credit to the wonderful developers of <a href="http://cakephp.org">CakePHP</a> &#8211; I&#8217;ve taken inspiration from their Model implementation while building this one for CodeIgniter. </p>
<h3>Download</h3>
<table cellspacing="0" cellpadding="2" border="0" width="698">
<tbody>
<tr>
<td width="42"><a target="_blank" href="http://www.phpfour.com/blog/downloads/model-ci" title="Download Model"><img src="http://www.phpfour.com/images/download.gif" border="0" /></a></td>
<td width="650"><strong>Model.php</strong><br/>Extended Model for CodeIgniter<br/>Downloaded: <strong></strong> times</td>
</tr>
</tbody>
</table>
<p><strong>MORE UPDATE:</strong> Download the version for CodeIgniter 1.7.x <a href="http://www.phpfour.com/blog/2009/02/updated-http-class-extended-model-codeigniter-cross-domain-ajax-php/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2008/07/extended-model-for-codeigniter/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Launch of Right Brain Solution Ltd.&#039;s website!</title>
		<link>http://phpfour.com/blog/2007/11/launch-of-right-brain-solution-ltds-website/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=launch-of-right-brain-solution-ltds-website</link>
		<comments>http://phpfour.com/blog/2007/11/launch-of-right-brain-solution-ltds-website/#comments</comments>
		<pubDate>Thu, 08 Nov 2007 19:46:56 +0000</pubDate>
		<dc:creator>Emran Hasan</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[RBS]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[company]]></category>
		<category><![CDATA[emran]]></category>
		<category><![CDATA[portfolio]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.phpfour.com/blog/2007/11/09/launch-of-right-brain-solution-ltds-website/</guid>
		<description><![CDATA[I would like to let you all know that we&#8217;ve just launched the new website of Right Brain Solution Ltd.. I would like to personally thank all our friends, families, associates, and well-wishers &#8211; for all their support and patience. Please have a look at the site and let us know your views, comments, ideas, [...]]]></description>
			<content:encoded><![CDATA[<p align="center"><a href="http://www.rightbrainsolution.com"><img src="http://www.rightbrainsolution.com/images/rbs_shot.png" title="Right Brain Solution Ltd." border="0" /></a></p>
<p>I would like to let you all know that we&#8217;ve just launched the new website of <a href="http://www.rightbrainsolution.com">Right Brain Solution Ltd.</a>. I would like to personally thank all our friends, families, associates, and well-wishers &#8211; for all their support and patience.</p>
<p>Please have a look at the site and let us know your views, comments, ideas, criticism &#8211; anything that you would like to share with us.</p>
<p>Thank you all!</p>
]]></content:encoded>
			<wfw:commentRss>http://phpfour.com/blog/2007/11/launch-of-right-brain-solution-ltds-website/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: phpfour.com @ 2012-02-04 12:06:58 -->
