<?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>Zack LivePHP | Best Premium WordPress Themes - Zack Live</title>
	<atom:link href="http://zacklive.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://zacklive.com</link>
	<description>Free Online Resource</description>
	<lastBuildDate>Wed, 21 Dec 2011 20:18:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Fuel: Band New PHP Framework Based on PHP 5.3</title>
		<link>http://zacklive.com/fuel-band-new-php-framework-based-on-php-5-3/3176/</link>
		<comments>http://zacklive.com/fuel-band-new-php-framework-based-on-php-5-3/3176/#comments</comments>
		<pubDate>Sun, 24 Apr 2011 16:05:44 +0000</pubDate>
		<dc:creator>Zack</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[Fuel]]></category>
		<category><![CDATA[Fuel PHP Framework]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP 5.3]]></category>

		<guid isPermaLink="false">http://zacklive.com/?p=3176</guid>
		<description><![CDATA[Fuel is a simple, flexible, community driven PHP 5.3 web framework based on the best ideas of other frameworks with a fresh start.]]></description>
			<content:encoded><![CDATA[<p><a href="http://zacklive.com/wp-content/uploads/2011/04/fuel-php-framework.png"><img class="aligncenter size-medium wp-image-3177" title="Fuel PHP Framework" src="http://zacklive.com/wp-content/uploads/2011/04/fuel-php-framework-550x222.png" alt="Fuel PHP Framework" width="550" height="222" /></a></p>
<p><strong>Fuel</strong> is a simple, flexible, community driven <strong>PHP 5.3</strong> web <strong>framework</strong> based on the best ideas of other frameworks with a fresh start.</p>
<p>The framework was started in late 2010 by <a href="http://dhorrigan.com/" target="_blank">Dan Horrigan</a> then shortly after the team grew to include <a href="http://philsturgeon.co.uk/" target="_blank">Phil Sturgeon</a>, <a href="http://jelmerschreuder.nl/" target="_blank">Jelmer Schreuder</a> and <a href="http://wanwizard.eu/" target="_blank">Harro Verton</a>. The team has decades of PHP experience between them and have all been involved with Open-Source projects such as CodeIgniter, <a href="http://pyrocms.com/" target="_blank">PyroCMS</a>, ExciteCMS and DataMapper ORM to name but a few.</p>
<p><a title="Fuel  PHP Framework" href="http://fuelphp.com/">VISIT Fuel PHP Framework</a></p>
<p><a title="Fuel PHP Framework" href="https://github.com/downloads/fuel/fuel/fuel-1.0-rc2.zip">DOWNLOAD Fuel PHP Framework</a></p>
<p>&nbsp;</p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://zacklive.com/fuel-cms-cms-based-on-codeigniter-php-framework/2052/" title="FUEL CMS: CMS Based on CodeIgniter PHP Framework">FUEL CMS: CMS Based on CodeIgniter PHP Framework</a></li><li><a href="http://zacklive.com/pyrocms-open-source-cms-based-on-codeigniter/2480/" title="PyroCMS: Open Source CMS Based on CodeIgniter">PyroCMS: Open Source CMS Based on CodeIgniter</a></li><li><a href="http://zacklive.com/say-hello-to-kohana-3/917/" title="Say Hello to Kohana 3">Say Hello to Kohana 3</a></li><li><a href="http://zacklive.com/hello-world-tutorial-for-kohana/15/" title="Hello World Tutorial for Kohana">Hello World Tutorial for Kohana</a></li><li><a href="http://zacklive.com/openpublic-drupal-based-cms-for-government/3149/" title="OpenPublic: Drupal-based CMS for Government">OpenPublic: Drupal-based CMS for Government</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://zacklive.com/fuel-band-new-php-framework-based-on-php-5-3/3176/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free jQuery Offline Learning Kit</title>
		<link>http://zacklive.com/free-jquery-offline-learning-kit/2649/</link>
		<comments>http://zacklive.com/free-jquery-offline-learning-kit/2649/#comments</comments>
		<pubDate>Sun, 16 Jan 2011 16:06:29 +0000</pubDate>
		<dc:creator>Zack</dc:creator>
				<category><![CDATA[Free Resource]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[jQuery Mobile]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ruby on Rials]]></category>

		<guid isPermaLink="false">http://zacklive.com/?p=2649</guid>
		<description><![CDATA[Addy Osmani released a Free jQuery Offline Learning Kit to help people to learn jQuery 1.4.3. The pack includes printable reference sheets so that whenever you’re wondering what selector or method might be best to use, you’ll have access to material that can assist with that.]]></description>
			<content:encoded><![CDATA[<p><a href="http://zacklive.com/wp-content/uploads/2011/01/jquery.jpg"><img class="aligncenter size-full wp-image-2650" title="Free jQuery Offline Learning Kit" src="http://zacklive.com/wp-content/uploads/2011/01/jquery.jpg" alt="Free jQuery Offline Learning Kit" width="540" height="342" /></a></p>
<p><a title="Addy Osmani" href="http://addyosmani.com/blog/jq143offlinelearningkit/">Addy Osmani</a> released a Free <a title="jQuery" href="http://zacklive.com/tag/jquery/">jQuery</a> Offline Learning Kit to help people to learn jQuery 1.4.3. The pack includes printable reference sheets so that whenever you’re wondering what selector or method might be best to use, you’ll have access to material that can assist with that.</p>
<p>The pack also comes with all the 1.4.3 documentation in an easily browseable offline format (with all our API examples included).</p>
<p>If you’re looking to start working with <strong>jQuery Mobile</strong>, it can be nice to have a minimalist example at your fingertips to start off with. That’s why this pack also includes a jQuery Mobile demo application – one for <strong>PHP</strong> developers and another for <strong>Rails</strong> developers.</p>
<p><strong>The Offline Learning Kit Includes</strong></p>
<ul>
<li>My 1.4.3 Selectors Printable that explains what each selector does and how it should be used (PDF)</li>
<li>The FutureColours 1.4.3 Cheatsheet showing all the different methods supported by 1.4.3 (PDF)</li>
<li>The<a href="http://jqapi.com/"> jQAPI</a> 1.4.3 Offline Documentation pack that lets you browse the documentation and API examples on your desktop (thanks to the guys at yayQuery and the awesome Ben Alman)</li>
<li>A Complete Developer’s jQuery 1.4.3 Mobile Demo Application (PHP courtesy of <a href="http://devgrow.com/">DevGrow</a>, Rails courtesy <a href="http://fuelyourcoding.com/">Fuel</a>)</li>
<li>Rebecca Murphy’s excellent jQuery Fundamentals book and exercises (PDF)</li>
<li>1.4.3 and our 1.4.4 Release Candidate Preview</li>
</ul>
<p><a title="DOWNLOAD jQuery Offline Learning Kit" href="http://addyosmani.com/blog/wp-content/uploads/2010/10/jquery1.4.3-offline-learningkit.zip">DOWNLOAD jQuery Offline Learning Kit</a></p>
<p><a title="Addy Osmani" href="http://addyosmani.com/blog/jq143offlinelearningkit/">VISIT Addy Osmani&#8217;s Blog</a></p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://zacklive.com/jquery-mobile-touch-optimized-web-framework-for-smartphones-tablets/2894/" title="jQuery Mobile: Touch-Optimized Web Framework for Smartphones &#038; Tablets">jQuery Mobile: Touch-Optimized Web Framework for Smartphones &#038; Tablets</a></li><li><a href="http://zacklive.com/zepto-js-js-framework-for-mobile-with-jquery-compatible-syntax/2632/" title="Zepto.js: JS Framework for Mobile, with jQuery-compatible Syntax">Zepto.js: JS Framework for Mobile, with jQuery-compatible Syntax</a></li><li><a href="http://zacklive.com/plupload-powerful-upload-handler-using-html5-gears-and-silverlight/2277/" title="Plupload: Powerful Upload Handler Using HTML5 Gears and Silverlight">Plupload: Powerful Upload Handler Using HTML5 Gears and Silverlight</a></li><li><a href="http://zacklive.com/formly-the-form-glamorizer-for-jquery/3200/" title="Formly: The Form Glamorizer for jQuery">Formly: The Form Glamorizer for jQuery</a></li><li><a href="http://zacklive.com/jquery-qrcode-js-browser-qrcode-generation-jquery-plugin/3196/" title="jquery.qrcode.js: Browser QRcode Generation JQuery Plugin">jquery.qrcode.js: Browser QRcode Generation JQuery Plugin</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://zacklive.com/free-jquery-offline-learning-kit/2649/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Health Check for WordPress 3.2</title>
		<link>http://zacklive.com/health-check-for-wordpress-3-2/2620/</link>
		<comments>http://zacklive.com/health-check-for-wordpress-3-2/2620/#comments</comments>
		<pubDate>Sat, 15 Jan 2011 04:56:55 +0000</pubDate>
		<dc:creator>Zack</dc:creator>
				<category><![CDATA[Blog and WordPress]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Health Check]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress 3.2]]></category>
		<category><![CDATA[WordPress Upgrade]]></category>

		<guid isPermaLink="false">http://zacklive.com/?p=2620</guid>
		<description><![CDATA[It's for sure that WordPress will no longer support PHP 4 and MySQL 4, WordPress 3.1 is the last version that support PHP 4. It requires PHP 5.2 since WordPress 3.2.

That means some hosting on which your WordPress is running now, may not be able to upgrade to WordPress 3.2. Thus WordPress releases an official plugin Health Check to help you to find out if you host is capable for WordPress 3.2.]]></description>
			<content:encoded><![CDATA[<p><a href="http://zacklive.com/wp-content/uploads/2011/01/wordpress.jpg"><img class="aligncenter size-full wp-image-2623" title="WordPress" src="http://zacklive.com/wp-content/uploads/2011/01/wordpress.jpg" alt="WordPress" width="550" height="250" /></a></p>
<p>It&#8217;s for sure that <a title="WordPress will no longer support PHP 4 and MySQL 4" href="http://wordpress.org/news/2010/07/eol-for-php4-and-mysql4/">WordPress will no longer support PHP 4 and MySQL 4</a>, WordPress 3.1 is the last version that support PHP 4. It requires PHP 5.2 since WordPress 3.2.</p>
<p>That means some hosting on which your WordPress is running now, may not be able to upgrade to WordPress 3.2. Thus WordPress releases an official plugin <a href="http://wordpress.org/extend/plugins/health-check/">Health Check</a> to help you to find out if you host is capable for WordPress 3.2.</p>
<h2>How to Health Check?</h2>
<p>Go to the Plugin page in your WordPress Admin, search for <a href="http://wordpress.org/extend/plugins/health-check/">Health Check</a> plugin, and install it.</p>
<p><a href="http://zacklive.com/wp-content/uploads/2011/01/WordPress-Health-Check.png"><img class="aligncenter size-medium wp-image-2621" title="WordPress Health Check" src="http://zacklive.com/wp-content/uploads/2011/01/WordPress-Health-Check-550x375.png" alt="WordPress Health Check" width="550" height="375" /></a></p>
<p>This plugin only does one thing, to check if you host is ready for WordPress 3.2. So if you see this, you are ready to go.</p>
<p><a href="http://zacklive.com/wp-content/uploads/2011/01/WordPress-Health-Check-Plugin.png"><img class="aligncenter size-medium wp-image-2622" title="WordPress Health Check Plugin" src="http://zacklive.com/wp-content/uploads/2011/01/WordPress-Health-Check-Plugin-550x249.png" alt="WordPress Health Check Plugin" width="550" height="249" /></a></p>
<p>And then, you can Deactivate the plugin and Delete it.</p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://zacklive.com/prestashop-open-source-e-commerce-software/2436/" title="PrestaShop: Open Source E-commerce  Software">PrestaShop: Open Source E-commerce  Software</a></li><li><a href="http://zacklive.com/addslashes-or-mysql-real-escape-string-avoid-sql-injection/906/" title="Addslashes or Mysql_real_escape_string to use to Avoid SQL Injection">Addslashes or Mysql_real_escape_string to use to Avoid SQL Injection</a></li><li><a href="http://zacklive.com/an-oop-way-to-work-with-mysql-database-in-php/894/" title="An OOP Way to Work with MySQL Database in PHP">An OOP Way to Work with MySQL Database in PHP</a></li><li><a href="http://zacklive.com/wordpress-month-special-offer-from-packtpub/3204/" title="WordPress Month Special Offer from PacktPub">WordPress Month Special Offer from PacktPub</a></li><li><a href="http://zacklive.com/fuel-band-new-php-framework-based-on-php-5-3/3176/" title="Fuel: Band New PHP Framework Based on PHP 5.3">Fuel: Band New PHP Framework Based on PHP 5.3</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://zacklive.com/health-check-for-wordpress-3-2/2620/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PrestaShop: Open Source E-commerce  Software</title>
		<link>http://zacklive.com/prestashop-open-source-e-commerce-software/2436/</link>
		<comments>http://zacklive.com/prestashop-open-source-e-commerce-software/2436/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 03:58:57 +0000</pubDate>
		<dc:creator>Zack</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[E-commerce]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PrestaShop]]></category>
		<category><![CDATA[Shopping Cart]]></category>

		<guid isPermaLink="false">http://zacklive.com/?p=2436</guid>
		<description><![CDATA[PrestaShop is a free open-source PHP and MySQL based e-commerse software. It was built to take advantage of essential Web 2.0 innovations such as dynamic AJAX-powered features and next-generation ergonomy. PrestaShop guides users through your product catalog intelligently and effortlessly, turning intrigued visitors into paying customers.]]></description>
			<content:encoded><![CDATA[<p><a href="http://zacklive.com/wp-content/uploads/2011/01/prestashop.png"><img class="aligncenter size-medium wp-image-2437" title="Prestashop" src="http://zacklive.com/wp-content/uploads/2011/01/prestashop-550x336.png" alt="Prestashop" width="550" height="336" /></a></p>
<p><a href="http://www.prestashop.com/">PrestaShop</a> is a free <a title="Open Source Projects" href="http://zacklive.com/tag/open-source/">open-source</a> <strong>PHP</strong> and <strong>MySQL</strong> based <a title="E-commerce" href="http://zacklive.com/tab/e-commerce">e-commerse</a> software. It was built to take advantage of essential Web 2.0 innovations such as dynamic <strong>AJAX</strong>-powered features and next-generation ergonomy. <em>PrestaShop</em> guides users through your product catalog intelligently and effortlessly, turning intrigued visitors into paying customers.</p>
<p><a title="PrestaShop" href="http://www.prestashop.com">VISIT PrestaShop</a></p>
<p><a title="PrestaShop" href="http://www.prestashop.com/en/downloads/">DOWNLOAD PrestaShop</a></p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://zacklive.com/monoql-ajax-based-mysql-admin-and-query-tool/2202/" title="Monoql: AJAX Based MySQL Admin and Query Tool">Monoql: AJAX Based MySQL Admin and Query Tool</a></li><li><a href="http://zacklive.com/free-icons-e-commerce-icons-set/3083/" title="Free Icons: E-commerce Icons Set">Free Icons: E-commerce Icons Set</a></li><li><a href="http://zacklive.com/health-check-for-wordpress-3-2/2620/" title="Health Check for WordPress 3.2">Health Check for WordPress 3.2</a></li><li><a href="http://zacklive.com/gestalt-write-ruby-python-xaml-code-in-your-xhtml/2293/" title="Gestalt: Write Ruby, Python &#038; XAML Code in Your (X)HTML">Gestalt: Write Ruby, Python &#038; XAML Code in Your (X)HTML</a></li><li><a href="http://zacklive.com/addslashes-or-mysql-real-escape-string-avoid-sql-injection/906/" title="Addslashes or Mysql_real_escape_string to use to Avoid SQL Injection">Addslashes or Mysql_real_escape_string to use to Avoid SQL Injection</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://zacklive.com/prestashop-open-source-e-commerce-software/2436/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP.js Brings PHP Functions to JavaScript</title>
		<link>http://zacklive.com/php-js-brings-php-functions-to-javascript/2327/</link>
		<comments>http://zacklive.com/php-js-brings-php-functions-to-javascript/2327/#comments</comments>
		<pubDate>Mon, 03 Jan 2011 04:26:37 +0000</pubDate>
		<dc:creator>Zack</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP.js]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://zacklive.com/?p=2327</guid>
		<description><![CDATA[php.js is an open source project that brings high-level PHP functions to low-level JavaScript platforms such as web browsers, browser extensions ( Mozilla/Firefox, Chrome ), AIR, and SSJS engines like V8 ( node.js,v8cgi ), Rhino, and SpiderMonkey ( CouchDB ).]]></description>
			<content:encoded><![CDATA[<p><a href="http://zacklive.com/wp-content/uploads/2011/01/phpjs.jpg"><img class="aligncenter size-full wp-image-2329" title="php.js" src="http://zacklive.com/wp-content/uploads/2011/01/phpjs.jpg" alt="php.js" width="480" height="200" /></a></p>
<p>php.js is an open source project that brings high-level PHP functions to low-level JavaScript platforms such as web browsers, browser extensions ( Mozilla/Firefox, Chrome ), AIR, and <a title="Server-side JavaScript" href="http://en.wikipedia.org/wiki/Server-side_JavaScript">SSJS</a> engines like V8 ( <a title="nodje.js uses the V8 engine" href="http://nodejs.org/">node.js</a>,<a title="v8cgi uses the V8 engine" href="http://code.google.com/p/v8cgi/">v8cgi</a> ), Rhino, and SpiderMonkey ( <a title="couchdb uses the SpiderMonkey engine" href="http://couchdb.apache.org/">CouchDB</a> ).</p>
<p>Find out more on <a title="Php.js" href="http://phpjs.org/pages/home">phpjs.org</a>.</p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://zacklive.com/jquery-qrcode-js-browser-qrcode-generation-jquery-plugin/3196/" title="jquery.qrcode.js: Browser QRcode Generation JQuery Plugin">jquery.qrcode.js: Browser QRcode Generation JQuery Plugin</a></li><li><a href="http://zacklive.com/eirte-open-source-wysiwyg-editor/3187/" title="eIRTE: Open Source WYSIWYG Editor ">eIRTE: Open Source WYSIWYG Editor </a></li><li><a href="http://zacklive.com/projekktor-free-html5-video-player/3181/" title="Projekktor: Free HTML5 Video Player">Projekktor: Free HTML5 Video Player</a></li><li><a href="http://zacklive.com/fuel-band-new-php-framework-based-on-php-5-3/3176/" title="Fuel: Band New PHP Framework Based on PHP 5.3">Fuel: Band New PHP Framework Based on PHP 5.3</a></li><li><a href="http://zacklive.com/gury-html5-canvas-utility-library/3172/" title="Gury: HTML5 Canvas Utility Library">Gury: HTML5 Canvas Utility Library</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://zacklive.com/php-js-brings-php-functions-to-javascript/2327/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FUEL CMS: CMS Based on CodeIgniter PHP Framework</title>
		<link>http://zacklive.com/fuel-cms-cms-based-on-codeigniter-php-framework/2052/</link>
		<comments>http://zacklive.com/fuel-cms-cms-based-on-codeigniter-php-framework/2052/#comments</comments>
		<pubDate>Thu, 16 Dec 2010 16:17:03 +0000</pubDate>
		<dc:creator>Zack</dc:creator>
				<category><![CDATA[Free Resource]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Content management System]]></category>
		<category><![CDATA[FUEL CMS]]></category>
		<category><![CDATA[Kohana]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP Framework]]></category>

		<guid isPermaLink="false">http://zacklive.com/?p=2052</guid>
		<description><![CDATA[FUEL CMS is a modular-based hybrid of a framework and a content management system. It's developed on the popular CodeIgniter PHP web framework and allows you to create your models, views and controllers like normal and only use the CMS part when and if you need it.]]></description>
			<content:encoded><![CDATA[<p><a href="http://zacklive.com/wp-content/uploads/2010/12/fuelcms.png"><img class="aligncenter size-medium wp-image-2053" title="FUEL CMS" src="http://zacklive.com/wp-content/uploads/2010/12/fuelcms-550x333.png" alt="FUEL CMS" width="550" height="333" /></a></p>
<p><a title="CodeIgniter PHP Framework" href="http://codeigniter.com/">CodeIgniter</a> is one of the best PHP frameworks, I personally prefer <a title="Kohana PHP Framework" href="http://kohanaphp.com/">Kohana</a>, but <strong>Kohana</strong> is developed from CodeIgniter.</p>
<p>What I want to talk about is a CMS(Content Management System) built upon <strong>CodeIgniter</strong> &#8211; <a title="FUEL CMS" href="http://www.getfuelcms.com/">FUEL CMS</a>.</p>
<blockquote><p>FUEL CMS is a modular-based hybrid of a framework and a content management system. It&#8217;s developed on the popular CodeIgniter PHP web framework and allows you to create your models, views and controllers like normal and only use the CMS part when and if you need it.</p></blockquote>
<p>As an open source project, it&#8217;s totally free.</p>
<p>You can find out more about <strong>FUEL CMS</strong> on its official page.</p>
<p>Visit <a title="FUEL CMS" href="http://www.getfuelcms.com/">FUEL CMS</a>.</p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://zacklive.com/fuel-band-new-php-framework-based-on-php-5-3/3176/" title="Fuel: Band New PHP Framework Based on PHP 5.3">Fuel: Band New PHP Framework Based on PHP 5.3</a></li><li><a href="http://zacklive.com/openpublic-drupal-based-cms-for-government/3149/" title="OpenPublic: Drupal-based CMS for Government">OpenPublic: Drupal-based CMS for Government</a></li><li><a href="http://zacklive.com/pyrocms-open-source-cms-based-on-codeigniter/2480/" title="PyroCMS: Open Source CMS Based on CodeIgniter">PyroCMS: Open Source CMS Based on CodeIgniter</a></li><li><a href="http://zacklive.com/hello-world-tutorial-for-kohana/15/" title="Hello World Tutorial for Kohana">Hello World Tutorial for Kohana</a></li><li><a href="http://zacklive.com/free-jquery-offline-learning-kit/2649/" title="Free jQuery Offline Learning Kit">Free jQuery Offline Learning Kit</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://zacklive.com/fuel-cms-cms-based-on-codeigniter-php-framework/2052/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redirect Users According to Browser Language</title>
		<link>http://zacklive.com/redirect-users-according-to-browser-language/923/</link>
		<comments>http://zacklive.com/redirect-users-according-to-browser-language/923/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 04:20:36 +0000</pubDate>
		<dc:creator>Zack</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Browser]]></category>
		<category><![CDATA[Multi Languges]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Redirection]]></category>

		<guid isPermaLink="false">http://zacklive.com/?p=923</guid>
		<description><![CDATA[I started a new blog Gearor.com, which is a gadgets and tech blog. I also set up a Chinese version using sub domain cn.Gearor.com. So I tried to do one thing, if visitors come with a Chinese browser, the website will automatically redirect them to the Chinese page. At the first time, I simply check [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-924" title="gearor-gadgets-tech-mag" src="http://zacklive.com/wp-content/uploads/2010/03/gearor-gadgets-tech-mag.jpg" alt="" width="550" height="250" /></p>
<p>I started a new blog <a title="Gadget Blog" href="http://gearor.com">Gearor.com</a>, which is a gadgets and tech blog. I also set up a Chinese version using sub domain cn.Gearor.com. So I tried to do one thing, if visitors come with a Chinese browser, the website will automatically redirect them to the Chinese page.</p>
<p>At the first time, I simply check the browser language, if it&#8217;s Chinese, the page will redirect to Chinese page. There is one problem with this method. I made a English link in Chinese page so that Chinese users can visit English page if they want, but after I added the redirection, Chinese users can&#8217;t visit English page, every time they click the link, they will be redirect to Chinese page.</p>
<p><span id="more-923"></span>This means I also need to check the referral URL, if it&#8217;s from my own website, geaor.com or cn.gearor.com, we don&#8217;t need to do the redirection. <a title="jasonbar from stackoverflow.com" href="http://stackoverflow.com/users/15099/jasonbar">Jasonbar</a> from <a title="Stack Over Flow" href="http://stackoverflow.com">StackOverFlow</a> helps me to fix this. By the way, StackOverFlow is a really great website, there are a lot of great programmers there, and they are all willing to help you. Here is my final code which is working fine on my website:</p>
<pre class="brush: php; title: ; notranslate">
if (!preg_match('%gearor.com%i', $_SERVER['HTTP_REFERER']))
	{
		if (!preg_match('%cn.gearor.com%i', $_SERVER['HTTP_REFERER']))
		{
			if (preg_match('/zh-cn/i', $_SERVER['HTTP_ACCEPT_LANGUAGE']))
				wp_redirect('http://cn.gearor.com');
		}
	}
</pre>
<p>If you are developing multi languages website, this may help you too.</p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://zacklive.com/fuel-band-new-php-framework-based-on-php-5-3/3176/" title="Fuel: Band New PHP Framework Based on PHP 5.3">Fuel: Band New PHP Framework Based on PHP 5.3</a></li><li><a href="http://zacklive.com/free-icons-high-resolution-browser-logos/2969/" title="Free Icons: High Resolution Browser Logos">Free Icons: High Resolution Browser Logos</a></li><li><a href="http://zacklive.com/free-jquery-offline-learning-kit/2649/" title="Free jQuery Offline Learning Kit">Free jQuery Offline Learning Kit</a></li><li><a href="http://zacklive.com/health-check-for-wordpress-3-2/2620/" title="Health Check for WordPress 3.2">Health Check for WordPress 3.2</a></li><li><a href="http://zacklive.com/prestashop-open-source-e-commerce-software/2436/" title="PrestaShop: Open Source E-commerce  Software">PrestaShop: Open Source E-commerce  Software</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://zacklive.com/redirect-users-according-to-browser-language/923/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Say Hello to Kohana 3</title>
		<link>http://zacklive.com/say-hello-to-kohana-3/917/</link>
		<comments>http://zacklive.com/say-hello-to-kohana-3/917/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 04:37:46 +0000</pubDate>
		<dc:creator>Zack</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Design Pattern]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[Hello World]]></category>
		<category><![CDATA[HMVC]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[Kohana 3]]></category>
		<category><![CDATA[Kohana PHP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://zacklive.com/?p=917</guid>
		<description><![CDATA[Kohana 3 has been released for a while. This is a redesign version of Kohana. Kohana 3 and 2 will both be in active, if you are new to Kohana, I suggest you to start with Kohana 3. The most important difference between these two version is that Kohana 3 uses a new design pattern [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-medium wp-image-919" title="kohana-3-php-logo" src="http://zacklive.com/wp-content/uploads/2010/02/kohana-3-php-logo-550x241.jpg" alt="" width="550" height="241" /><br />
<a title="Kohana PHP Framework" href="http://kohanaphp.com/">Kohana 3</a> has been released for a while. This is a redesign version of <strong>Kohana</strong>. <strong>Kohana 3</strong> and 2 will both be in active, if you are new to Kohana, I suggest you to start with Kohana 3. The most important difference between these two version is that Kohana 3 uses a new <strong>design pattern</strong> <strong>HMVC</strong> rather than <strong>MVC</strong> as Kohana 2 is using. What is HMVC? These two articles may help you understand it:</p>
<ol>
<li><a title="HMVC Design Pattern" href="http://en.wikipedia.org/wiki/Presentation-abstraction-control">Presentation-abstraction-control</a></li>
<li><a title="HMVC Design Pattern" href="http://ooerabegins.wordpress.com/2009/05/29/hmvc-pattern1/">HMVC Pattern For GUI Of Swing/GWT/Desktop Application</a></li>
</ol>
<p>You can download Kohana 3 here:</p>
<p><a title="Kohana 3 Download" href="http://dev.kohanaphp.com/projects/kohana3/files">Kohana 3 Download</a></p>
<p><span id="more-917"></span>As usual, it&#8217;s extremely easy to install Kohana, unzip the download file, put the Kohana folder to your web server, change permissions of following folders to <strong>777</strong>:</p>
<ol>
<li><strong>application/cache</strong></li>
<li><strong>application/logs</strong></li>
</ol>
<p>Finally make some changes to application/bootstrap.php:</p>
<ol>
<li>Change <a title="Kohana PHP Timezone" href="http://php.net/timezones">timezone</a></li>
<li>Set the <strong>base_url</strong></li>
</ol>
<p>That&#8217;s it, your Kohana is ready to go. Visit your website which should be the base_url you set above, you will see the Environment Tests page:</p>
<p style="text-align: center;"><a href="http://zacklive.com/wp-content/uploads/2010/02/kohana-install-1.jpg"><img class="size-medium wp-image-918 aligncenter" title="kohana-install-1" src="http://zacklive.com/wp-content/uploads/2010/02/kohana-install-1-550x369.jpg" alt="" width="550" height="369" /></a></p>
<p>Notice the green background text, it&#8217;s telling you to delete the install.php file in you Kohana root. And then refresh the page, you will see &#8220;hello, world!&#8221; text. Where is the text come from? Open application-&gt;classes-&gt;controller, there is a welcome.php there. Double click the file, Here is the code:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php defined('SYSPATH') or die('No direct script access.');

class Controller_Welcome extends Controller {

	public function action_index()
	{
		$this-&gt;request-&gt;response = 'hello, world!';
	}

} // End Welcome
</pre>
<p>This is the Welcome controller, the only thing it do is to print the text &#8216;hello, world!&#8217; to the screen. You can try to output other text by change:</p>
<pre class="brush: php; title: ; notranslate">
$this-&gt;request-&gt;response = 'hello, world!';
</pre>
<p>to:</p>
<pre class="brush: php; title: ; notranslate">
$this-&gt;request-&gt;response = 'hello, Kohana 3! I am Zack from ZackLive.com~';
</pre>
<p>Now you&#8217;ve got your Kohana installed, try to get your hands dirty.</p>
<p>Some useful resource for Kohana 3:</p>
<ol>
<li><a title="Kohana 3 User Guide" href="http://v3.kohanaphp.com/guide/about.kohana">Kohana 3 User Guide</a></li>
<li><a title="Kohana 3 Unofficial Wiki" href="http://kerkness.ca/wiki/doku.php">Kohana 3 Unofficial Wiki</a></li>
<li><a title="Kohana 3 API Cheat Sheet" href="http://kohana.sher.pl/cs">Kohana 3 API Cheat Sheet</a></li>
</ol>
<p>If you&#8217;ve got any questions about Kohana 3, feel free to ask me by commenting here or post on <a title="Kohana forum" href="http://forum.kohanaphp.com/">Kohana forum</a>.</p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://zacklive.com/fuel-band-new-php-framework-based-on-php-5-3/3176/" title="Fuel: Band New PHP Framework Based on PHP 5.3">Fuel: Band New PHP Framework Based on PHP 5.3</a></li><li><a href="http://zacklive.com/hello-world-tutorial-for-kohana/15/" title="Hello World Tutorial for Kohana">Hello World Tutorial for Kohana</a></li><li><a href="http://zacklive.com/treesaver-javascript-framework-for-creating-magazine-style-layouts/3026/" title="Treesaver: JavaScript Framework for Creating Magazine-style Layouts">Treesaver: JavaScript Framework for Creating Magazine-style Layouts</a></li><li><a href="http://zacklive.com/free-jquery-offline-learning-kit/2649/" title="Free jQuery Offline Learning Kit">Free jQuery Offline Learning Kit</a></li><li><a href="http://zacklive.com/health-check-for-wordpress-3-2/2620/" title="Health Check for WordPress 3.2">Health Check for WordPress 3.2</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://zacklive.com/say-hello-to-kohana-3/917/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Addslashes or Mysql_real_escape_string to use to Avoid SQL Injection</title>
		<link>http://zacklive.com/addslashes-or-mysql-real-escape-string-avoid-sql-injection/906/</link>
		<comments>http://zacklive.com/addslashes-or-mysql-real-escape-string-avoid-sql-injection/906/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 04:25:29 +0000</pubDate>
		<dc:creator>Zack</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Addslashes]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Mysql_real_escape_string]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL Injection]]></category>

		<guid isPermaLink="false">http://zacklive.com/?p=906</guid>
		<description><![CDATA[I was reading some articles about avoiding SQL injection. People used to use addslashes() function, and later more and more programmers are using mysql_real_escape_string(). What&#8217;s the difference between these two functions? Alan Storm from StackOverFlow gives a description which is the best as I know: PHP&#8217;s mysql_real_escape_string function will, more or less, ask mysql what [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://zacklive.com/wp-content/uploads/2010/02/SQL-Injection.jpg" alt="" title="SQL-Injection" width="550" height="250" class="aligncenter size-full wp-image-907" /><br />
I was reading some articles about <strong>avoiding SQL injection</strong>. People used to use <em>addslashes()</em> function, and later more and more programmers are using <em>mysql_real_escape_string()</em>. What&#8217;s the difference between these two functions? <a title="addslashes or mysql_real_escape_string" href="http://stackoverflow.com/questions/534742/what-does-mysql-real-escape-string-do-that-addslashes-doesnt">Alan Storm</a> from StackOverFlow gives a description which is the best as I know:</p>
<blockquote><p>PHP&#8217;s mysql_real_escape_string function will, more or less, <strong>ask mysql what character(s) needs to be escaped</strong>, where the addslashses function will just add a backslash in front of and any single quote (&#8216;), double quote (&#8220;), backslash (\) or NUL (the NULL byte) character.</p></blockquote>
<p>In the same post, Waage says that:</p>
<blockquote><p>mysql_real_escape_string adds slashes to:<br />
\x00, \n, \r, \, &#8216;, &#8221; and \x1a. characters.<br />
Where addslashes only adds slashes to:<br />
&#8216; \ and NUL
</p></blockquote>
<p><span id="more-906"></span>So <strong>that means mysql_real_escape_string() is better than addslashes()</strong>, I thought. If you still prefer <em>addslashes()</em>, you may like to have a look at this function from <a href="http://www.php5.idv.tw/modules.php?mod=books&#038;act=show&#038;shid=2475" title="PHP Addslashes SQL Injection">php5.idv.tw</a>:</p>
<pre class="brush: php; title: ; notranslate">
function quotes($content)
{
	//if magic_quotes_gpc=Off
	if (!get_magic_quotes_gpc())
	{
		//if $content is an array
		if (is_array($content))
		{
			foreach ($content as $key=&gt;$value)
			{
				$content[$key] = addslashes($value);
			}
		} else
		{
			//if $content is not an array
			addslashes($content);
		}
	} else
	{
		//if magic_quotes_gpc=On do nothing
	}
	return $content;
}
</pre>
<p>This function checks if <strong>magic_quotes_gpc</strong> is on, if so, we don&#8217;t need to do <em>addslashes()</em>. if not, we do <em>addslashes()</em> in different way for array and non-array content.</p>
<p>Of course, you can write a similar function using <em>mysql_real_escape_string()</em>. Here is my version:</p>
<pre class="brush: php; title: ; notranslate">
function quotes($content)
{
	//if $content is an array
	if (is_array($content))
	{
		foreach ($content as $key=&gt;$value)
		{
			$content[$key] = mysql_real_escape_string($value);
		}
	} else
	{
		//if $content is not an array
		mysql_real_escape_string($content);
	}
	return $content;
}
</pre>
<p>Basically, just replace <em>addslashes()</em> with <em>mysql_real_escape_string()</em>. You can use this function like this:</p>
<pre class="brush: php; title: ; notranslate">
$name = quotes($_POST['user']);
$password = quotes($_POST['password']);
</pre>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://zacklive.com/health-check-for-wordpress-3-2/2620/" title="Health Check for WordPress 3.2">Health Check for WordPress 3.2</a></li><li><a href="http://zacklive.com/prestashop-open-source-e-commerce-software/2436/" title="PrestaShop: Open Source E-commerce  Software">PrestaShop: Open Source E-commerce  Software</a></li><li><a href="http://zacklive.com/an-oop-way-to-work-with-mysql-database-in-php/894/" title="An OOP Way to Work with MySQL Database in PHP">An OOP Way to Work with MySQL Database in PHP</a></li><li><a href="http://zacklive.com/fuel-band-new-php-framework-based-on-php-5-3/3176/" title="Fuel: Band New PHP Framework Based on PHP 5.3">Fuel: Band New PHP Framework Based on PHP 5.3</a></li><li><a href="http://zacklive.com/free-jquery-offline-learning-kit/2649/" title="Free jQuery Offline Learning Kit">Free jQuery Offline Learning Kit</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://zacklive.com/addslashes-or-mysql-real-escape-string-avoid-sql-injection/906/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An OOP Way to Work with MySQL Database in PHP</title>
		<link>http://zacklive.com/an-oop-way-to-work-with-mysql-database-in-php/894/</link>
		<comments>http://zacklive.com/an-oop-way-to-work-with-mysql-database-in-php/894/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 19:30:46 +0000</pubDate>
		<dc:creator>Zack</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Object Oriented Programming]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Web Application]]></category>

		<guid isPermaLink="false">http://zacklive.com/?p=894</guid>
		<description><![CDATA[This is my learning note of PHP and OOP(Object Oriented Programming) from Brian Muse&#8217;s tutorial, if you are new to OOP, you may find something helpful in this post. If you are a professional, I would appreciate it if you can give me some further advices or refer me for further tutorials. Create a Demo [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://zacklive.com/wp-content/uploads/2010/02/php_mysql_oop.jpg" alt="" title="php_mysql_oop" width="400" height="300" class="aligncenter size-full wp-image-896" /><br />
This is my learning note of PHP and OOP(Object Oriented Programming) from <a href="http://buildinternet.com/2009/12/creating-your-first-php-application-part-1/" title="Creating Your First PHP Application">Brian Muse&#8217;s tutorial</a>, if you are new to OOP, you may find something helpful in this post. If you are a professional, I would appreciate it if you can give me some further advices or refer me for further tutorials.</p>
<h2>Create a Demo Database with a users table</h2>
<p>Basically, an oop way to work with database means to create a class for database. Let&#8217;s create a new file named DB.class.php for our database class. We also need a demo database with a users table, here is the SQL:</p>
<pre class="brush: sql; title: ; notranslate">
CREATE TABLE IF NOT EXISTS `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(50) NOT NULL,
  `password` varchar(50) NOT NULL,
  `email` varchar(50) NOT NULL,
  `join_date` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `username` (`username`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
</pre>
<p><span id="more-894"></span></p>
<h2>The DB Class and its Properties</h2>
<p>We have a class named DB in DB.class.php, at the very beginning we can write the follow codes:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
//DB.class.php

class DB{

}

?&gt;
</pre>
<p>And then, we need to consider about the properties and functions of the class. In this case, we need the following properties:</p>
<ul>
<li>$db_name:  database name</li>
<li>$db_user: database username</li>
<li>$db_pass: database password</li>
<li>$db_host: host of the database</li>
</ul>
<p>Because these variables are not necessary to be accessed from outside the class, we will define them as &#8220;protected&#8221;:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
//DB.class.php

class DB{

    protected $db_name = 'yourdatabasename';
    protected $db_user = 'databaseusername';
    protected $db_pass = 'databasepassword';
    protected $db_host = 'localhost';  

}

?&gt;
</pre>
<p>They can be used inside the class by using $this->db_name, $this->db_user, etc. That&#8217;s all properties we need, and now we need to think about what functions we need. </p>
<h2>Functions of DB Class</h2>
<p>While using database, the first thing we need to do is to connect to the database, so the first function should be connect(). There are several common operations we also need: insert, update, select and delete. One more thing we need to think about is that  the select function will pull some data out from the database, the database normally returns row set, it is better that we convert row set into associative array for later use. So we add a function processRowSet() for this. Let&#8217;s code the first function, connect():</p>
<pre class="brush: php; title: ; notranslate">
    //Connect to the database.
    //You need to call this on every page using database

    public function connect() {
        $connection = mysql_connect($this-&gt;db_host, $this-&gt;db_user, $this-&gt;db_pass);
        mysql_select_db($this-&gt;db_name);  

        return true;
    }
</pre>
<p>Not thing special in this function, just connect to the database using mysql_connect(), select database by using mysql_select_db(), and then return true telling the function executed successfully. The next function is insert(), here is codes:</p>
<pre class="brush: php; title: ; notranslate">
    //Inserts a new row into the database.
    //takes an array of data, where the keys in the array are the column names
    //and the values are the data that will be inserted into those columns.
    //$table is the name of the table.
    public function insert($data, $table) {  

        $columns = &quot;&quot;;
        $values = &quot;&quot;;  

        foreach ($data as $column =&gt; $value) {
            $columns .= ($columns == &quot;&quot;) ? &quot;&quot; : &quot;, &quot;;
            $columns .= $column;
            $values .= ($values == &quot;&quot;) ? &quot;&quot; : &quot;, &quot;;
            $values .= $value;
        }  

        $sql = &quot;insert into $table ($columns) values ($values)&quot;;  

        mysql_query($sql) or die(mysql_error());  

        //return the ID of the user in the database.
        return mysql_insert_id();  

    }
</pre>
<p>The foreach loop is to combine each column and value in $data into columns and values, separating each other by comma, so that we can use one query to insert all data. After inserting, we return the id of the new row(which should be user in this tutorial).</p>
<p>Before we go to select(), we need to write the codes of processRowSet():</p>
<pre class="brush: php; title: ; notranslate">
    //takes a mysql row set and returns an associative array, where the keys
    //in the array are the column names in the row set. If singleRow is set to
    //true, then it will return a single row instead of an array of rows.
    public function processRowSet($rowSet, $singleRow=false)
    {
        $resultArray = array();
        while($row = mysql_fetch_assoc($rowSet))
        {
            array_push($resultArray, $row);
        }  

        if($singleRow === true)
            return $resultArray[0];  

        return $resultArray;
    }
</pre>
<p>This function loops through each row in $rowSet, converts each row into an associative array($row) using mysql_fetch_assoc() function, and then pushes each array into one array($resultArray) which will be returned in the end of the function. If the $singleRow is set to true, only the first array will be returned.</p>
<p>Now let&#8217;s see the select() function:</p>
<pre class="brush: php; title: ; notranslate">
    //Select rows from the database.
    //returns a full row or rows from $table using $where as the where clause.
    //return value is an associative array with column names as keys.
    public function select($table, $where) {
        $sql = &quot;SELECT * FROM $table WHERE $where&quot;;
        $result = mysql_query($sql);
        if(mysql_num_rows($result) == 1)
            return $this-&gt;processRowSet($result, true);  

        return $this-&gt;processRowSet($result);
    }
</pre>
<p>This function select some data from the database, converts row set into associative array using processRowSet(), here you can see how the $singleRow parameter is used.</p>
<p>The next function is update():</p>
<pre class="brush: php; title: ; notranslate">
    //Updates a current row in the database.
    //takes an array of data, where the keys in the array are the column names
    //and the values are the data that will be inserted into those columns.
    //$table is the name of the table and $where is the sql where clause.
    public function update($data, $table, $where) {
        foreach ($data as $column =&gt; $value) {
            $sql = &quot;UPDATE $table SET $column = $value WHERE $where&quot;;
            mysql_query($sql) or die(mysql_error());
        }
        return true;
    }
</pre>
<p>This function loops through $data, update each $column with $value according to $where, if everything goes well, return true, otherwise, die with MySQL error message.</p>
<p>The final one is the delete() function:</p>
<pre class="brush: php; title: ; notranslate">
   public function delete($table, $where) {
        $sql = &quot;DELETE * FROM $table WHERE $where&quot;;
        mysql_query($sql) or die(mysql_error());
        return true;
}
</pre>
<p>This may be the simplest one, just run the query and return true or die with error message.</p>
<h2>Using DB Class</h2>
<p>As a result, the DB class should be like this:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
//DB.class.php

class DB{

    protected $db_name = 'yourdatabasename';
    protected $db_user = 'databaseusername';
    protected $db_pass = 'databasepassword';
    protected $db_host = 'localhost';  

    //Connect to the database.
    //You need to call this on every page using database

    public function connect() {
        $connection = mysql_connect($this-&gt;db_host, $this-&gt;db_user, $this-&gt;db_pass);
        mysql_select_db($this-&gt;db_name);  

        return true;
    } 

    //Inserts a new row into the database.
    //takes an array of data, where the keys in the array are the column names
    //and the values are the data that will be inserted into those columns.
    //$table is the name of the table.
    public function insert($data, $table) {  

        $columns = &quot;&quot;;
        $values = &quot;&quot;;  

        foreach ($data as $column =&gt; $value) {
            $columns .= ($columns == &quot;&quot;) ? &quot;&quot; : &quot;, &quot;;
            $columns .= $column;
            $values .= ($values == &quot;&quot;) ? &quot;&quot; : &quot;, &quot;;
            $values .= $value;
        }  

        $sql = &quot;insert into $table ($columns) values ($values)&quot;;  

        mysql_query($sql) or die(mysql_error());  

        //return the ID of the user in the database.
        return mysql_insert_id();  

    } 

    //takes a mysql row set and returns an associative array, where the keys
    //in the array are the column names in the row set. If singleRow is set to
    //true, then it will return a single row instead of an array of rows.
    public function processRowSet($rowSet, $singleRow=false)
    {
        $resultArray = array();
        while($row = mysql_fetch_assoc($rowSet))
        {
            array_push($resultArray, $row);
        }  

        if($singleRow === true)
            return $resultArray[0];  

        return $resultArray;
    } 

    //Select rows from the database.
    //returns a full row or rows from $table using $where as the where clause.
    //return value is an associative array with column names as keys.
    public function select($table, $where) {
        $sql = &quot;SELECT * FROM $table WHERE $where&quot;;
        $result = mysql_query($sql);
        if(mysql_num_rows($result) == 1)
            return $this-&gt;processRowSet($result, true);  

        return $this-&gt;processRowSet($result);
    } 

    //Updates a current row in the database.
    //takes an array of data, where the keys in the array are the column names
    //and the values are the data that will be inserted into those columns.
    //$table is the name of the table and $where is the sql where clause.
    public function update($data, $table, $where) {
        foreach ($data as $column =&gt; $value) {
            $sql = &quot;UPDATE $table SET $column = $value WHERE $where&quot;;
            mysql_query($sql) or die(mysql_error());
        }
        return true;
    } 

   public function delete($table, $where) {
        $sql = &quot;DELETE * FROM $table WHERE $where&quot;;
        mysql_query($sql) or die(mysql_error());
        return true;
    }

}

?&gt;
</pre>
<p>Here is a sample of how to use the DB class:</p>
<pre class="brush: php; title: ; notranslate">
//create an instance of the DB class
$db = new DB(); 

//connect to the database
$db-&gt;connect(); 

$data = array(
    &quot;username&quot; =&gt; &quot;'Jack'&quot;,
    &quot;email&quot; =&gt; &quot;'jack@email.com'&quot;
);

//insert a new user
$db-&gt;insert($data, 'users');

//change the email of Jack
$data = array(
    &quot;username&quot; =&gt; &quot;Jack&quot;,
    &quot;email&quot; =&gt; &quot;jack.gmail@gmail.com&quot;
);

//update Jack
$db-&gt;update($data, 'users', 'id = 1');

//delete Jack
$db-&gt;delete('users', 'id = 1');
</pre>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://zacklive.com/health-check-for-wordpress-3-2/2620/" title="Health Check for WordPress 3.2">Health Check for WordPress 3.2</a></li><li><a href="http://zacklive.com/prestashop-open-source-e-commerce-software/2436/" title="PrestaShop: Open Source E-commerce  Software">PrestaShop: Open Source E-commerce  Software</a></li><li><a href="http://zacklive.com/addslashes-or-mysql-real-escape-string-avoid-sql-injection/906/" title="Addslashes or Mysql_real_escape_string to use to Avoid SQL Injection">Addslashes or Mysql_real_escape_string to use to Avoid SQL Injection</a></li><li><a href="http://zacklive.com/fuel-band-new-php-framework-based-on-php-5-3/3176/" title="Fuel: Band New PHP Framework Based on PHP 5.3">Fuel: Band New PHP Framework Based on PHP 5.3</a></li><li><a href="http://zacklive.com/embedded-help-system-providing-help-where-help-is-needed/2729/" title="Embedded Help System: Providing Help Where Help Is Needed">Embedded Help System: Providing Help Where Help Is Needed</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://zacklive.com/an-oop-way-to-work-with-mysql-database-in-php/894/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hello World Tutorial for Kohana</title>
		<link>http://zacklive.com/hello-world-tutorial-for-kohana/15/</link>
		<comments>http://zacklive.com/hello-world-tutorial-for-kohana/15/#comments</comments>
		<pubDate>Tue, 01 Jul 2008 04:44:47 +0000</pubDate>
		<dc:creator>Zack</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[Kohana]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blogiii.com/zack/?p=12</guid>
		<description><![CDATA[It seems unnecessary to write a Hello World tuorial for a PHP framework, because when someone comes to framework, he is no longer a beginner, can figure out his own Hello World. But this idea comes up in my brain, and I guess it might be helpful for someone who is the first time to [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center"><a href="http://i252.photobucket.com/albums/hh6/Xanxuss/kohana-hello.png"><img class="aligncenter" src="http://i252.photobucket.com/albums/hh6/Xanxuss/kohana-hello.png" alt="Kohana hello world" width="450" height="405" /></a></p>
<p>It seems unnecessary to write a Hello World tuorial for a PHP framework, because when someone comes to framework, he is no longer a beginner, can figure out his own Hello World. But this idea comes up in my brain, and I guess it might be helpful for someone who is the first time to work with MVC or OOP. It&#8217;s quite simple, let&#8217;s get started.</p>
<p>You should have <a title="kohana tutorial" href="http://blogiii.com/zack/install-kohana-on-windows/11/">installed Kohana</a> correctly, now we create a <em>hello.php</em> in /application/controllers/, here is the content of the file:</p>
<blockquote><p>&lt;?php<br />
/**<br />
* Hello World controller<br />
*/<br />
class Hello_Controller extends Template_Controller<br />
{<br />
function __construct()<br />
{<br />
parent::__construct();<br />
}</p>
<p>function index()<br />
{<br />
$this-&gt;template-&gt;title = &#8220;Hello World&#8221;;<br />
$this-&gt;template-&gt;content = &#8220;Hello, welcome to Kohana World !!!&#8221;;<br />
}<br />
}<br />
?&gt;</p></blockquote>
<p><span id="more-15"></span></p>
<p>We have a <em>Hello </em>Controller with a index method, so we can call this page in the URL: localhost/kohana/index.php/hello. If you cannot understand this, you may want to see &#8216;<em>Show me, don&#8217;t tell me</em>&#8216; section in <a title="kohana 101" href="http://oscar.nom.za/dl/kohana101.pdf">Kohana 101</a>. In the <em>Hello</em> Controller, we set the title and content of our Hello World page, of course you can change the title and content into anything.</p>
<p>Now we have a Controller, we also need a View to reveal the page. Create a <em>template.php</em> in /applicaion/views/, and type in the fellowing codes:</p>
<blockquote><p>&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Strict//EN&#8221; &#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&#8221;&gt;<br />
&lt;html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221; xml:lang=&#8221;en&#8221; lang=&#8221;en&#8221;&gt;</p>
<p>&lt;head&gt;</p>
<p>&lt;title&gt;&lt;?php echo $title ?&gt;&lt;/title&gt;</p>
<p>&lt;body&gt;</p>
<p>&lt;h2&gt;&lt;?php echo $title ?&gt;&lt;/h2&gt;</p>
<p>&lt;p&gt;&lt;?php echo $content ?&gt;&lt;/p&gt;</p>
<p>&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p>Very simple HTML codes, echo the title and content set in the <em>Hello </em>Controller to the page, that&#8217;s all what it does. You can see how Kohana works, processing in Controller, sending the result to View, and the View exhibit the page.</p>
<p>Usually I&#8217;d like to add a profiler to a example page, so that we can see some system information. It&#8217;s very easy to do that, just add one line to the Construt function in the Controller:</p>
<blockquote><p>$this-&gt;profiler = new Profiler;</p></blockquote>
<p>So the Hello Controller file should look like this:</p>
<blockquote><p>&lt;?php<br />
/**<br />
* Hello World controller<br />
*/<br />
class Hello_Controller extends Template_Controller<br />
{<br />
function __construct()<br />
{<br />
parent::__construct();<br />
$this-&gt;profiler = new Profiler;<br />
}</p>
<p>function index()<br />
{<br />
$this-&gt;template-&gt;title = &#8220;Hello World&#8221;;<br />
$this-&gt;template-&gt;content = &#8220;Hello, welcome to Kohana World !!!&#8221;;<br />
}<br />
}<br />
?&gt;</p></blockquote>
<p>We can now visit <em>localhost/kohana/index.php/hello</em>, you will have a page the same as the image above.</p>
<p>You already have some basic concepts of Kohana now, I highly recommand you to read <a title="kohana 101" href="http://oscar.nom.za/dl/kohana101.pdf">Kohana 101</a>, or if you are even not sure how to setup your own Kohana, you can read my post, <a title="kohana tutorial" href="http://blogiii.com/zack/install-kohana-on-windows/11/">Install Kohana on Windows</a>. Hope this can help you.</p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://zacklive.com/fuel-band-new-php-framework-based-on-php-5-3/3176/" title="Fuel: Band New PHP Framework Based on PHP 5.3">Fuel: Band New PHP Framework Based on PHP 5.3</a></li><li><a href="http://zacklive.com/fuel-cms-cms-based-on-codeigniter-php-framework/2052/" title="FUEL CMS: CMS Based on CodeIgniter PHP Framework">FUEL CMS: CMS Based on CodeIgniter PHP Framework</a></li><li><a href="http://zacklive.com/say-hello-to-kohana-3/917/" title="Say Hello to Kohana 3">Say Hello to Kohana 3</a></li><li><a href="http://zacklive.com/install-kohana-on-windows/14/" title="Install Kohana on Windows">Install Kohana on Windows</a></li><li><a href="http://zacklive.com/treesaver-javascript-framework-for-creating-magazine-style-layouts/3026/" title="Treesaver: JavaScript Framework for Creating Magazine-style Layouts">Treesaver: JavaScript Framework for Creating Magazine-style Layouts</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://zacklive.com/hello-world-tutorial-for-kohana/15/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

