<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3" -->
<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/"
	>

<channel>
	<title>FROST</title>
	<link>http://zeratool.com/blog</link>
	<description>FRee and Open Source Technologies</description>
	<pubDate>Mon, 04 Feb 2008 04:58:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3</generator>
	<language>en</language>
			<item>
		<title>Creating your own library in CodeIgniter</title>
		<link>http://zeratool.com/blog/2008/02/03/creating-your-own-library-in-codeigniter/</link>
		<comments>http://zeratool.com/blog/2008/02/03/creating-your-own-library-in-codeigniter/#comments</comments>
		<pubDate>Sun, 03 Feb 2008 18:12:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[CodeIgniter]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://zeratool.com/blog/2008/02/03/creating-your-own-library-in-codeigniter/</guid>
		<description><![CDATA[Creating your own library in CodeIgniter
You setup CodeIgniter and you see how it really helps your life as a developer doing you job. But you want your codes to be reusable into your other projects. Yes you can say i'll just copy-paste the codes, but there's more elegant idea, build it as a library. What [...]]]></description>
			<content:encoded><![CDATA[<p>Creating your own library in CodeIgniter</p>
<p>You setup CodeIgniter and you see how it really helps your life as a developer doing you job. But you want your codes to be reusable into your other projects. Yes you can say i'll just copy-paste the codes, but there's more elegant idea, build it as a library. What is a library, IMO, a library is a file or a component that can be easily inject into an existing system.</p>
<p>Nuf said, here's the code:</p>
<p>&lt;?php<br />
/**<br />
* class for easy uploading of files for CI<br />
* @author zeratool<br />
* @uses CI::Upload class<br />
*<br />
*/</p>
<p>class lib_upload<br />
{<br />
function __construct()<br />
{<br />
$config['upload_path'] = '/your/path/to/upload/dir/';<br />
$config['allowed_types'] = 'gif|jpg|png';</p>
<p>$this-&gt;CI =&amp; get_instance();<br />
$this-&gt;CI-&gt;load-&gt;library('upload', $config);<br />
}</p>
<p>/**<br />
* uploads the file<br />
* @access public<br />
*<br />
*/<br />
function do_upload()<br />
{<br />
$data = $this-&gt;validate();<br />
return $data;<br />
}</p>
<p>/**<br />
* cehcks the file uploaded<br />
* @access private<br />
* @return mixed, string if error, array of file uploaded info on success<br />
*/<br />
private function validate()<br />
{<br />
if (! $this-&gt;CI-&gt;upload-&gt;do_upload())<br />
{<br />
return $this-&gt;CI-&gt;upload-&gt;display_errors();<br />
}<br />
else<br />
{</p>
<p>return $this-&gt;CI-&gt;upload-&gt;data();<br />
}<br />
}</p>
<p>}</p>
<p>?&gt;</p>
<p>Now in order to use our library, we have to create our Controller and View files.</p>
<p>First, the controller:</p>
<p>&lt;?php</p>
<p>class upload extends Controller<br />
{<br />
function __construct()<br />
{<br />
parent::Controller();</p>
<p>//we use our custom library by loading it first<br />
$this-&gt;load-&gt;library('lib_upload');<br />
}</p>
<p>function index()<br />
{<br />
// we load our view file here, in our case it's the upload form<br />
$this-&gt;load-&gt;view('uploadform');<br />
}</p>
<p>function do_upload()<br />
{<br />
// we call the do_upload method of our library<br />
$ok = $this-&gt;lib_upload-&gt;do_upload();</p>
<p>// we checked if the upload is successful or not<br />
// if it displays the array of the file information, try to check your<br />
// upload directory and look for the file there<br />
// NOTE : you must set the upload dir enough write priveledges</p>
<p>echo '&lt;pre&gt;';<br />
print_r($ok);</p>
<p>}<br />
}</p>
<p>?&gt;</p>
<p>Here's our View  file</p>
<p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;Upload Form&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;</p>
<p>&lt;?=$error;?&gt;</p>
<p>&lt;?=form_open_multipart('upload/file/do_upload'); ?&gt;</p>
<p>&lt;input type="file" name="userfile" size="20" /&gt;</p>
<p>&lt;br /&gt;&lt;br /&gt;</p>
<p>&lt;input type="submit" value="upload" /&gt;</p>
<p>&lt;/form&gt;</p>
<p>&lt;/body&gt;<br />
&lt;/html&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://zeratool.com/blog/2008/02/03/creating-your-own-library-in-codeigniter/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Blog title changed</title>
		<link>http://zeratool.com/blog/2008/01/25/blog-title-changed/</link>
		<comments>http://zeratool.com/blog/2008/01/25/blog-title-changed/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 20:34:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Openness]]></category>

		<guid isPermaLink="false">http://zeratool.com/blog/2008/01/25/blog-title-changed/</guid>
		<description><![CDATA["Frameworks that work" was the old title of this humble blog. I switched to "FROST!" so I can write anything open source. Hoping for more frequent postings.
]]></description>
			<content:encoded><![CDATA[<p>"Frameworks that work" was the old title of this humble blog. I switched to "FROST!" so I can write anything open source. Hoping for more frequent postings.</p>
]]></content:encoded>
			<wfw:commentRss>http://zeratool.com/blog/2008/01/25/blog-title-changed/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Caching using Memcached</title>
		<link>http://zeratool.com/blog/2008/01/24/php-caching-using-memcached/</link>
		<comments>http://zeratool.com/blog/2008/01/24/php-caching-using-memcached/#comments</comments>
		<pubDate>Thu, 24 Jan 2008 21:14:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Caching]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://zeratool.com/blog/2008/01/25/php-caching-using-memcached/</guid>
		<description><![CDATA[Why cached? It's simple, you want speed. How? Say you have search application on your php webapp that yields thousands of results. Of course these are divided in a nice paginated links. Without caching, everytime the user jumps from each paged result links, your app will query your database, which adds overhead.
By using caching, you're [...]]]></description>
			<content:encoded><![CDATA[<p>Why cached? It's simple, you want speed. How? Say you have search application on your php webapp that yields thousands of results. Of course these are divided in a nice paginated links. Without caching, everytime the user jumps from each paged result links, your app will query your database, which adds overhead.</p>
<p>By using caching, you're storing the result set in a temporary container(in case of memcached, it's the memory) so that only one call to the DB are done.</p>
<p>Here's the logic.</p>
<p>1. First check if we have cached the result set coming from DB.</p>
<p>2. If not, run the query.</p>
<p>3. Now, save the result set into cache.</p>
<p>4. If yes(see #2), get the result set from the cache.</p>
<p>Why Memcached? Well IMHO, it's fast and it's supported by php using libmemcache. You can see the complete details and can download it from <a href="http://danga.com/memcached/" title="danga.com" target="_blank">danga.com</a></p>
<p>Can you provide sample snippet? See below.</p>
<p>&lt;?php</p>
<p>// first we set up memcached connection</p>
<p>$memcache_obj = new Memcache;<br />
$memcache_obj-&gt;connect($memcache_host, 11211);</p>
<p>// now let's check for cached data</p>
<p>if(!$memcache_obj-&gt;get('unique_key')) {</p>
<p>// your very large query here and assign the result in $resultset</p>
<p>// save the db result into the cache, set the cache lifetime for 5 minutes(60 sec * 5)</p>
<p>$memcache_obj-&gt;set('unique_key', $resultset, MEMCACHE_COMPRESSED, 300);</p>
<p>} else {</p>
<p>$resultset = $memcache_obj-&gt;get('unique_key');</p>
<p>}</p>
<p>// do useful things with the $resultset</p>
<p>?&gt;</p>
<p>It's so simple , yet so helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://zeratool.com/blog/2008/01/24/php-caching-using-memcached/feed/</wfw:commentRss>
		</item>
		<item>
		<title>CodeIgniter 101</title>
		<link>http://zeratool.com/blog/2007/12/09/codeigniter-101/</link>
		<comments>http://zeratool.com/blog/2007/12/09/codeigniter-101/#comments</comments>
		<pubDate>Mon, 10 Dec 2007 06:25:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[CodeIgniter]]></category>

		<guid isPermaLink="false">http://zeratool.com/blog/2007/12/09/codeigniter-101/</guid>
		<description><![CDATA[You want to use codeigniter but don't know where to start? Below are the lists to get you up and running.
1. Download the zip/tar package at http://codeigniter.com/ , click the link "Download Codeigniter" or click here
2. Extract the files under your document root, on windows if you are using wamp5, it's under c:\wamp\www, on linux, [...]]]></description>
			<content:encoded><![CDATA[<p>You want to use codeigniter but don't know where to start? Below are the lists to get you up and running.</p>
<p>1. Download the zip/tar package at http://codeigniter.com/ , click the link "Download Codeigniter" or click <a href="http://codeigniter.com/download.php" title="Download CodeIgniter" target="_blank">here</a></p>
<p>2. Extract the files under your document root, on windows if you are using wamp5, it's under c:\wamp\www, on linux, the default is under "/var/www". Create a folder say "CodeIgniter" and put all the files here.</p>
<p>3. You're done! Fire up your browser and open the url "http://localhost/CodeIgniter/" and you will see a welcome page saying "Welcome to CodeIgniter". You can see the screenshot below.</p>
<p><a href="http://zeratool.com/blog/wp-content/uploads/2007/12/screenshot_codeigniter.png" title="CodeIgniter Setup"><img src="http://zeratool.com/blog/wp-content/uploads/2007/12/screenshot_codeigniter.thumbnail.png" alt="CodeIgniter Setup" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://zeratool.com/blog/2007/12/09/codeigniter-101/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
