<?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>.:: Kohaci Site ::. &#187; PHP</title>
	<atom:link href="http://kohaci.com/topik/php/feed" rel="self" type="application/rss+xml" />
	<link>http://kohaci.com</link>
	<description></description>
	<lastBuildDate>Thu, 29 Jul 2010 05:12:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Value to Variable</title>
		<link>http://kohaci.com/2010/03/24/value-to-variable.html</link>
		<comments>http://kohaci.com/2010/03/24/value-to-variable.html#comments</comments>
		<pubDate>Wed, 24 Mar 2010 07:48:08 +0000</pubDate>
		<dc:creator>kohaci</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming-Q]]></category>
		<category><![CDATA[call by reference]]></category>
		<category><![CDATA[value to variable]]></category>
		<category><![CDATA[variable]]></category>

		<guid isPermaLink="false">http://kohaci.com/?p=249</guid>
		<description><![CDATA[Seringkali gw melihat kode fungsi yang dtuliskan seperti bawah ini

	function contoh_fungsi&#40;$a = NULL, $b = 8, $c = NULL, $d = 'D', $e = '150', $f = '30', $g = NULL, $h = 7200&#41; &#123;
		// bla ... bla ..
	&#125;

Kode di atas benar, dan tentu aja gak salah sama sekali ^-^ . Tapi sungguh menyenangkan (bagi [...]]]></description>
			<content:encoded><![CDATA[<p>Seringkali gw melihat kode fungsi yang dtuliskan seperti bawah ini</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">function</span> contoh_fungsi<span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$b</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">,</span> <span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$d</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'D'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$e</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'150'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$f</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'30'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$g</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$h</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">7200</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// bla ... bla ..</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Kode di atas benar, dan tentu aja gak salah sama sekali ^-^ . Tapi sungguh menyenangkan (bagi gw) jika disederhanakan lagi fungsinya menjadi :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">       <span style="color: #000000; font-weight: bold;">function</span> contoh_fungsi<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// bla ... bla ..</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Lho kok bisa?<span id="more-249"></span></p>
<p>Kembali ke contoh kode awal, jika ingin mengganti value dari variable  $a saja :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000088;">$a</span>	<span style="color: #339933;">=</span> <span style="color: #cc66cc;">3600</span>
	contoh_fungsi<span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span></pre></div></div>

<p>Begitupun kalau gak ada value default yang berubah</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	contoh_fungsi<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span></pre></div></div>

<p>Tapi yang menjadi persoalan gimana kalau kita hanya ingin mengganti value dari variable $h saja, dengan cara penulisan di atas maka cara memanggilnya adalah .</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000088;">$h</span>	<span style="color: #339933;">=</span> <span style="color: #cc66cc;">3600</span>
	contoh_fungsi<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'D'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'150'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'30'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$h</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span></pre></div></div>

<p>Bukan masalah panjangnya, yang repot adalah gw harus tahu nilai default dari masing-masing variable , dan variablenya itu ada banyak. Karena daya ingat gw gak terlalu terlalu <img src='http://kohaci.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  , bagi gw itu cukup merepotkan jika memanggil fungsi tersebut jika hanya mengubah satu variable defaultny saja yang kebetulan ada posisi akhir. <img src='http://kohaci.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>So, lebih baik dibikin alternatif, manfaatkan fleksibiltas variable di PHP yang on-the-fly (kata sebagian orang). Kata kuncinya adalah <strong>&#8220;value to variable&#8221;</strong> , maksudnya mengubah value menjadi variable , misalkan ada value &#8220;hai&#8221; maka akan dijadikan $hai.</p>
<p>contoh :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$var</span>	<span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;hai&quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$$var</span>	<span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;freddy ganteng&quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$var</span> <span style="color: #006699; font-weight: bold;">$hai</span>&quot;</span> <span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// print &quot;hai freddy ganteng&quot;</span></pre></td></tr></table></div>

<p>Modifikasi untuk fungsi di atas</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> contoh_fungsi<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$defaults</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'a'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'b'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'c'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'d'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'D'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'e'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'150'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'f'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'30'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'g'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'h'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">7200</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$defaults</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$$key</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$val</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// bla .. bla ..</span>
	<span style="color: #666666; font-style: italic;">// contoh bla .. bla ..</span>
	<span style="color: #b1b100;">echo</span> 	<span style="color: #0000ff;">&quot;a =&gt; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;b =&gt; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$b</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;c =&gt; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;d =&gt; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$d</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;e =&gt; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$e</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;f =&gt; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$f</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;g =&gt; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$g</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;h =&gt; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$h</span> <span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Cara memanggil</span>
<span style="color: #000088;">$data</span>	<span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'a'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'h'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">2500</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
contoh_fungsi<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Semoga berguna. CMIIW.</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://delicious.com/post?url=http://kohaci.com/2010/03/24/value-to-variable.html&amp;title=Value+to+Variable" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://kohaci.com/2010/03/24/value-to-variable.html&amp;t=Value+to+Variable" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Value+to+Variable+-+http://b2l.me/k2g2d+&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://kohaci.com/2010/03/24/value-to-variable.html/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://kohaci.com/2010/03/24/value-to-variable.html&amp;n=Value+to+Variable&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://kohaci.com/2010/03/24/value-to-variable.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Menghindari duplikasi nama file saat proses upload</title>
		<link>http://kohaci.com/2009/09/04/menghindari-duplikasi-nama-file-saat-proses-upload.html</link>
		<comments>http://kohaci.com/2009/09/04/menghindari-duplikasi-nama-file-saat-proses-upload.html#comments</comments>
		<pubDate>Fri, 04 Sep 2009 07:37:44 +0000</pubDate>
		<dc:creator>kohaci</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming-Q]]></category>

		<guid isPermaLink="false">http://kohaci.com/?p=216</guid>
		<description><![CDATA[Seringkali kita membuat kode (PHP) untuk membuat upload file seperti di bawah ini :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Folder tempat isi file upload
$dir		= &#34;upload/&#34; ;
&#160;
// Nama File yang diupload
$filename	= $_FILES&#91;'upload'&#93;&#91;'name'&#93; ;
&#160;
// Spesifikasi lokasi file yang akan diupload
$target_dir = $dir . $filename ;
&#160;
// upload
if&#40;move_uploaded_file&#40;$_FILES&#91;'upload'&#93;&#91;'tmp_name'&#93;, $target_dir&#41;&#41;
	return TRUE ;
else 
	return FALSE ;

Kode di atas memiliki kelemahan, salah satunya adalah jika diupload file [...]]]></description>
			<content:encoded><![CDATA[<p>Seringkali kita membuat kode (PHP) untuk membuat <em>upload file</em> seperti di bawah ini :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Folder tempat isi file upload</span>
<span style="color: #000088;">$dir</span>		<span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;upload/&quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Nama File yang diupload</span>
<span style="color: #000088;">$filename</span>	<span style="color: #339933;">=</span> <span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'upload'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Spesifikasi lokasi file yang akan diupload</span>
<span style="color: #000088;">$target_dir</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dir</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$filename</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// upload</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">move_uploaded_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'upload'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tmp_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$target_dir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">TRUE</span> <span style="color: #339933;">;</span>
<span style="color: #b1b100;">else</span> 
	<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">FALSE</span> <span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Kode di atas memiliki kelemahan, salah satunya adalah jika di<em>upload file</em> <strong>berkas.odt</strong> kedalam folder &#8220;<strong>upload</strong>&#8220;, dimana sebelumnya di dalam folder <strong>upload</strong> telah ada file <em>berkas.odt</em>, maka <em>berkas.odt</em> yang lama akan te-<em>replace</em> oleh <em>berkas.odt yang baru</em>. Mungkin tidak akan ada masalah jika <em>file-file</em> tersebut serupa dan sama. Tapi jika <em>file-file</em> tersebut serupa tapi tidak sama (maksudnya nama <em>file</em> sama tetapi isi atau konten di dalamnya berbeda), tentu proses <span id="more-216"></span>pengoleksian <em>file-file</em> yang telah di<em>upload</em> menjadi kacau, dan pasti kode di atas salah.</p>
<p>Untuk itu perlu diperbaiki kode program di atas untuk menghindari terjadi duplikasi nama <em>file</em> saat proses <em>upload</em>.</p>
<p>Berikut contoh kode perbaikannya :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Folder tempat isi file upload</span>
<span style="color: #000088;">$dir</span>		<span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;upload/&quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Nama file yang diupload</span>
<span style="color: #000088;">$filename</span>	<span style="color: #339933;">=</span> <span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'upload'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Spesifikasi lokasi file yang akan diupload</span>
<span style="color: #000088;">$target_dir</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dir</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$filename</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* 
* Gunakan fungsi file_exists() untuk memeriksa apakah 
* file X telah ada sebelumnya di folder Y 
*/</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$target_dir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">/* 
	* Iterasi sampai 100 dg asusmi file duplikasi (bernama sama) itu maksimal 100, 
	* lebih dari itu ... TERLALU (mode on Bang Rhoma) :-p
	*/</span>
	<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
		<span style="color: #000088;">$target_dir</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dir</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'-'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$filename</span> <span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">/* 
		* Misal file berkas.odt ada di folder sebelumnya, 
		* maka file berkas.odt yang baru akan direname menjadi 1-berkas.odt
		*/</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$target_dir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// upload</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">move_uploaded_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'upload'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tmp_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$target_dir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 
	<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">TRUE</span> <span style="color: #339933;">;</span>
<span style="color: #b1b100;">else</span> 
	<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">FALSE</span> <span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Selamat mencoba. CMIIW.</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://delicious.com/post?url=http://kohaci.com/2009/09/04/menghindari-duplikasi-nama-file-saat-proses-upload.html&amp;title=Menghindari+duplikasi+nama+%3Cem%3Efile%3C%2Fem%3E+saat+proses+%3Cem%3Eupload%3C%2Fem%3E" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://kohaci.com/2009/09/04/menghindari-duplikasi-nama-file-saat-proses-upload.html&amp;t=Menghindari+duplikasi+nama+%3Cem%3Efile%3C%2Fem%3E+saat+proses+%3Cem%3Eupload%3C%2Fem%3E" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Menghindari+duplikasi+nama+%3Cem%3Efile%3C%2Fem%3E+saat+proses+%3Cem%3Eupload%3C%2Fem%3E+-+http://b2l.me/capey+&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://kohaci.com/2009/09/04/menghindari-duplikasi-nama-file-saat-proses-upload.html/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://kohaci.com/2009/09/04/menghindari-duplikasi-nama-file-saat-proses-upload.html&amp;n=Menghindari+duplikasi+nama+%3Cem%3Efile%3C%2Fem%3E+saat+proses+%3Cem%3Eupload%3C%2Fem%3E&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://kohaci.com/2009/09/04/menghindari-duplikasi-nama-file-saat-proses-upload.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Tip dan Trik Optimasasi Query SQL (bag 1)</title>
		<link>http://kohaci.com/2009/03/27/tip-dan-trik-optimasasi-query-sql-bag-1.html</link>
		<comments>http://kohaci.com/2009/03/27/tip-dan-trik-optimasasi-query-sql-bag-1.html#comments</comments>
		<pubDate>Fri, 27 Mar 2009 00:43:17 +0000</pubDate>
		<dc:creator>kohaci</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming-Q]]></category>

		<guid isPermaLink="false">http://kohaci.com/?p=167</guid>
		<description><![CDATA[Misalkan gw punya tiga tabel di database yang mana ketiga database tersebut saling berhubungan , yaitu Tabel Mahasiswa , MataKuliah, dan Mahasiswa_MataKuliah .
Tabel Mahasiswa terdiri dari dua kolom , yaitu : ID_Mahasiswa dan Nama_Mahasiswa. Tabel MataKuliah terdiri dari dua kolom, yaitu ID_MataKuliah dan Nama_MataKuliah. Dan terakhir tabel Mahasiswa_MataKuliah yang terdiri dari ID_Mahasiswa dan ID_MataKuliah. Tabel [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Misalkan gw punya tiga tabel di database yang mana ketiga database tersebut saling berhubungan , yaitu Tabel Mahasiswa , MataKuliah, dan Mahasiswa_MataKuliah .</p>
<p style="text-align: justify;">Tabel <strong>Mahasiswa</strong> terdiri dari dua kolom , yaitu : <em>ID_Mahasiswa</em> dan <em>Nama_Mahasiswa</em>. Tabel <strong>MataKuliah</strong> terdiri dari dua kolom, yaitu <em>ID_MataKuliah</em> dan <em>Nama_MataKuliah</em>. Dan terakhir tabel <strong>Mahasiswa_MataKuliah</strong> yang terdiri dari <em>ID_Mahasiswa</em> dan <em>ID_MataKuliah</em>. Tabel terakhir menunjukkan hubungan antara Mahasiswa dan MataKuliah yang bersifat many to many, dimana satu mahasiswa bisa memiliki banyak mata kuliah dan begitu juga sebaliknya.</p>
<p><span id="more-167"></span></p>
<p style="text-align: justify;">Proses Pertama : <strong>INSERT</strong> .</p>
<p style="text-align: justify;">Anggap semua terjadi dalam satu proses sekaligus.</p>
<p style="text-align: justify;">Cara primitif <img src='http://kohaci.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  :</p>
<p style="text-align: justify;">

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// INSERT Mahasiswa</span>
<span style="color: #000088;">$sql_mahasiswa</span>	<span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO Mahasiswa VALUES (NULL, '&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$Nama_Mahasiswa</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;')&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// INSERT MataKuliah</span>
<span style="color: #000088;">$sql_matakuliah</span>	<span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO Mahasiswa VALUES (NULL, '&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$Nama_MataKuliah</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;')&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Ambil ID Mahasiswa yang baru dimasukkan</span>
<span style="color: #000088;">$sql_id_mahasiswa</span>	<span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT ID_Mahasiswa FROM Mahasiswa ORDER BY ID_Mahasiswa DESC LIMIT 1&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$rs_id_mahasiswa</span>	<span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql_id_mahasiswa</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// dan bla... bla.. sehingga</span>
<span style="color: #000088;">$ID_Mahasiswa</span>		<span style="color: #339933;">=</span> <span style="color: #000088;">$rs_id_mahasiswa</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ID_Mahasiswa'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Ambil ID MataKuliah yang baru dimasukkan</span>
<span style="color: #000088;">$sql_id_matakuliah</span>	<span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT ID_MataKuliah FROM MataKuliah ORDER BY ID_MataKuliah DESC LIMIT 1&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$rs_id_matakuliah</span>	<span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql_id_matakuliah</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// dan bla... bla.. sehingga</span>
<span style="color: #000088;">$ID_MataKuliah</span>		<span style="color: #339933;">=</span> <span style="color: #000088;">$rs_id_matakuliah</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ID_MataKuliah'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Sehingga tinggal dimasukkan ke Tabel Mahasiswa_MataKuliah</span>
<span style="color: #000088;">$sql_mahasiswa_matakuliah</span>	<span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO Mahasiswa_MataKuliah VALUES ('&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$ID_Mahasiswa</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;','&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$ID_MataKuliah</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;')&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>	
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

</p>
<p style="text-align: justify;">Cara optimasasi :</p>
<p style="text-align: justify;">

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// INSERT Mahasiswa</span>
<span style="color: #000088;">$sql_mahasiswa</span>	<span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO Mahasiswa VALUES (NULL, '&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$Nama_Mahasiswa</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;')&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// INSERT MataKuliah</span>
<span style="color: #000088;">$sql_matakuliah</span>	<span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO Mahasiswa VALUES (NULL, '&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$Nama_MataKuliah</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;')&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Langsung dimasukkan ke tabel Mahasiswa_MataKuliah</span>
<span style="color: #000088;">$sql_mahasiswa_matakuliah</span>	<span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO Mahasiswa_Matakuliah
							SELECT 	(SELECT ID_Mahasiswa FROM Mahasiswa ORDER BY ID_Mahasiswa DESC LIMIT 1),
								(SELECT ID_MataKuliah FROM MataKuliah ORDER BY ID_MataKuliah DESC LIMIT 1)
						&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// ATAU .... ?</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

</p>
<p style="text-align: justify;">Proses Kedua :  <strong>READ</strong></p>
<p style="text-align: justify;">

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Proses read dengan mengambil seluruh mahasiswa berikut mata kuliah yang diambilnya</span>
<span style="color: #000088;">$sql</span>	<span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;
			SELECT Nama_Mahasiswa, Nama_MataKuliah 
				FROM Mahasiswa M, MataKuliah MK, Mahasiswa_MataKuliah MM 
				WHERE 	MM.ID_Mahasiswa	= M.ID_Mahasiswa AND
					MM.ID_MataKuliah= MK.ID_Mahasiswa
		&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">// Proses read dengan megambil beberapa mahasiswa ($limit) berikut mata kuliah yang diambilnya</span>
<span style="color: #666666; font-style: italic;">// $limit = batasan yang ditampilkan</span>
<span style="color: #666666; font-style: italic;">// $start = mulai dari baris berapa ditampilkan</span>
<span style="color: #000088;">$sql</span>	<span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;
			SELECT Nama_Mahasiswa, Nama_MataKuliah 
				FROM 	(SELECT ID_Mahasiswa, Nama_Mahasiswa FROM Mahasiswa LIMIT &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$start</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$limit</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;) M, 
					MataKuliah MK, Mahasiswa_MataKuliah MM 
				WHERE 	MM.ID_Mahasiswa	= M.ID_Mahasiswa AND
					MM.ID_MataKuliah= MK.ID_Mahasiswa
		&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

</p>
<p style="text-align: justify;">Semoga bermanfaat . Good Luck.</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://delicious.com/post?url=http://kohaci.com/2009/03/27/tip-dan-trik-optimasasi-query-sql-bag-1.html&amp;title=Tip+dan+Trik+Optimasasi+Query+SQL+%28bag+1%29" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://kohaci.com/2009/03/27/tip-dan-trik-optimasasi-query-sql-bag-1.html&amp;t=Tip+dan+Trik+Optimasasi+Query+SQL+%28bag+1%29" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Tip+dan+Trik+Optimasasi+Query+SQL+%28bag+1%29+-+http://b2l.me/cag63+&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://kohaci.com/2009/03/27/tip-dan-trik-optimasasi-query-sql-bag-1.html/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://kohaci.com/2009/03/27/tip-dan-trik-optimasasi-query-sql-bag-1.html&amp;n=Tip+dan+Trik+Optimasasi+Query+SQL+%28bag+1%29&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://kohaci.com/2009/03/27/tip-dan-trik-optimasasi-query-sql-bag-1.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Trik Menghapus Method Index di CI (Kasus : Pagination)</title>
		<link>http://kohaci.com/2009/03/20/trik-menghapus-method-index-di-ci.html</link>
		<comments>http://kohaci.com/2009/03/20/trik-menghapus-method-index-di-ci.html#comments</comments>
		<pubDate>Fri, 20 Mar 2009 07:05:36 +0000</pubDate>
		<dc:creator>kohaci</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming-Q]]></category>

		<guid isPermaLink="false">http://kohaci.com/?p=162</guid>
		<description><![CDATA[Umumnya jika membuat pagination di CI, dasarnya seperti ini :

class Blog extends Controller &#123;
&#160;
    public function  __construct&#40;&#41; &#123;
        parent::Controller&#40;&#41;;
    &#125;
&#160;
    public function index&#40;&#41; &#123;
        $this-&#62;load-&#62;library&#40;'pagination'&#41;;
&#160;
       [...]]]></description>
			<content:encoded><![CDATA[<p>Umumnya jika membuat pagination di CI, dasarnya seperti ini :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Blog <span style="color: #000000; font-weight: bold;">extends</span> Controller <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span>  __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        parent<span style="color: #339933;">::</span><span style="color: #004000;">Controller</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pagination'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'base_url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> site_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'blog/index'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span> 
        <span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'total_rows'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'200'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'per_page'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'20'</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pagination</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">initialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pagination</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create_links</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p> </p>
<p>Tautannya akan membentuk seperti ini :</p>
<blockquote><p><strong>www.example.com/blog/index/10</strong></p></blockquote>
<p>Dengan <strong>Blog</strong> sebagai nama class dan <strong>index</strong> sebagai nama method. Permasalahannya saat ini gw pengen menghapus nama methodnya, sehingga di URL akan kelihatan seperti ini :</p>
<blockquote><p><strong>www.example.com/blog/10</strong></p></blockquote>
<p>Cara dengan menambahkan method <em>_remap()</em> , source codenya akan seperti ini :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #000000; font-weight: bold;">class</span> Blog <span style="color: #000000; font-weight: bold;">extends</span> Controller <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span>  __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        parent<span style="color: #339933;">::</span><span style="color: #004000;">Controller</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pagination'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'base_url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> site_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'blog'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span> 
        <span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'total_rows'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'200'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'per_page'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'20'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cur_page'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$page</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Halaman terakhir yang dilihat</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pagination</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">initialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pagination</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create_links</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Method untuk menyederhanakan URI</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> _remap<span style="color: #009900;">&#40;</span><span style="color: #000088;">$method</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">index</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$method</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Pengembangannya selanjutnya diserahkan kepada pembaca. Happy coding!</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://delicious.com/post?url=http://kohaci.com/2009/03/20/trik-menghapus-method-index-di-ci.html&amp;title=Trik+Menghapus+Method+Index+di+CI+%28Kasus+%3A+Pagination%29" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://kohaci.com/2009/03/20/trik-menghapus-method-index-di-ci.html&amp;t=Trik+Menghapus+Method+Index+di+CI+%28Kasus+%3A+Pagination%29" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Trik+Menghapus+Method+Index+di+CI+%28Kasus+%3A+Pagination%29+-+http://b2l.me/capp6+&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://kohaci.com/2009/03/20/trik-menghapus-method-index-di-ci.html/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://kohaci.com/2009/03/20/trik-menghapus-method-index-di-ci.html&amp;n=Trik+Menghapus+Method+Index+di+CI+%28Kasus+%3A+Pagination%29&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://kohaci.com/2009/03/20/trik-menghapus-method-index-di-ci.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Web Crawling</title>
		<link>http://kohaci.com/2009/01/02/web-crawling.html</link>
		<comments>http://kohaci.com/2009/01/02/web-crawling.html#comments</comments>
		<pubDate>Fri, 02 Jan 2009 01:35:02 +0000</pubDate>
		<dc:creator>kohaci</dc:creator>
				<category><![CDATA[IT-Q]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming-Q]]></category>

		<guid isPermaLink="false">http://kohaci.com/?p=146</guid>
		<description><![CDATA[Gambar di atas menjelaskan struktur dari web crawler dan indexing yang nantinya mendukung proses sistem mesin pencari. Pada tulisan kali ini hanya akan dibahas secara singkat tentang web crawling.

Web crawling adalah proses mengambil kumpulan halaman dari sebuah web untuk dilakukan pengindeksan sehingga mendukung kinerja mesin pencari. Tujuan dari proses crawling adalah mempercepat dan mengefisienkan kumpulan [...]]]></description>
			<content:encoded><![CDATA[<div class="wp-caption aligncenter" style="width: 410px"><a href="http://picasaweb.google.com/lh/photo/qDFZ034o3xoYA6lr3RTETA?feat=embedwebsite"><img title="Berbagai macam komponen sebuah web search engine (Manning et al. 2008)" src="http://lh5.ggpht.com/_IL56WrTPeME/SV1hp2AYALI/AAAAAAAACMM/jd_Yn8hIkMk/s400/various-component-of-a-web-search-engine.jpg" alt="Berbagai macam komponen sebuah web search engine (Manning et al. 2008)" width="400" height="247" /></a><p class="wp-caption-text">Berbagai macam komponen sebuah web search engine (Manning et al. 2008)</p></div>
<p style="text-align: justify;">Gambar di atas menjelaskan struktur dari <em>web crawler</em> dan <em>indexing</em> yang nantinya mendukung proses sistem mesin pencari. Pada tulisan kali ini hanya akan dibahas secara singkat tentang <em>web crawling</em>.</p>
<p><span id="more-146"></span></p>
<p style="text-align: justify;"><em>Web crawling</em> adalah proses mengambil kumpulan halaman dari sebuah web untuk dilakukan pengindeksan sehingga mendukung kinerja mesin pencari. Tujuan dari proses crawling adalah mempercepat dan mengefisienkan kumpulan halaman web dengan cepat, mengumpulkan struktur tautan yang menghubungkan kumpulan halaman web tersebut (Manning <em>et al.</em> 2008).</p>
<p style="text-align: justify;">Salah satu contoh situs yang menerapkan <em>web crawling</em> adalah <a href="http://www.webcrawler.com/">www.webcrawler.com</a> . Di samping situs-situ mesin pencari terkemuka tentunya, seperti Google, Yahoo, Ask, Live, dan lain sebagainya.</p>
<p style="text-align: justify;">Algoritma dari <em>crawling</em> adalah sebagai berikut : (Rada Mihalcea 2006)*</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">Initialize queue <span style="color: #009900;">&#40;</span>Q<span style="color: #009900;">&#41;</span> with initial set of known URL’s.
<span style="color: #202020;">Until</span> Q empty or page or time limit exhausted<span style="color: #339933;">:</span>
     Pop URL<span style="color: #339933;">,</span> L<span style="color: #339933;">,</span> from front of Q.
<span style="color: #202020;">If</span> L is not to an HTML page <span style="color: #009900;">&#40;</span>.<span style="color: #202020;">gif</span><span style="color: #339933;">,</span> .<span style="color: #202020;">jpeg</span><span style="color: #339933;">,</span> .<span style="color: #202020;">ps</span><span style="color: #339933;">,</span> .<span style="color: #202020;">pdf</span><span style="color: #339933;">,</span> .<span style="color: #202020;">ppt</span>…<span style="color: #009900;">&#41;</span>
              <span style="color: #b1b100;">continue</span> loop.
      <span style="color: #202020;">If</span> already visited L<span style="color: #339933;">,</span> <span style="color: #b1b100;">continue</span> loop.
      	<span style="color: #202020;">Download</span> page<span style="color: #339933;">,</span> P<span style="color: #339933;">,</span> <span style="color: #b1b100;">for</span> L.
<span style="color: #202020;">If</span> cannot download P <span style="color: #009900;">&#40;</span>e.<span style="color: #202020;">g</span>. <span style="color: #0000dd;">404</span> error<span style="color: #339933;">,</span> robot excluded<span style="color: #009900;">&#41;</span>
              <span style="color: #b1b100;">continue</span> loop.
<span style="color: #202020;">Index</span> P <span style="color: #009900;">&#40;</span>e.<span style="color: #202020;">g</span>. <span style="color: #202020;">add</span> to inverted index or store cached copy<span style="color: #009900;">&#41;</span>.
      <span style="color: #202020;">Parse</span> P to obtain list of new links N.
<span style="color: #202020;">Append</span> N to the end of Q.</pre></td></tr></table></div>

<p style="text-align: justify;">Algoritma di atas menjelaskan pengambilan konten (berupa teks) dari suatu situs sampai ke halaman terakhir yang ditandai dengan tidak ada lagi tautan yang merujuk ke halaman selanjutnya.</p>
<p style="text-align: justify;">Pada tulisan kali ini akan diberi contoh cara mengambil konten dari suatu situs berupa tautan. Dengan menggunakan bahasa pemrograman PHP, library CURL, dan penggunaan regex (regular expression).</p>
<p style="text-align: justify;">Sumber kode :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Fungsi untuk mengambil meng-scan seluruh konten dan disimpan dalam format teks</span>
<span style="color: #666666; font-style: italic;">// Menggunakan library CURL</span>
<span style="color: #000000; font-weight: bold;">function</span> scanPage<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_TIMEOUT<span style="color: #339933;">,</span> <span style="color: #cc66cc;">120</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//timeout after 120 seconds</span>
	<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$result</span><span style="color: #339933;">=</span><span style="color: #990000;">curl_exec</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">curl_close</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$result</span> <span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://www.kohaci.com/&quot;</span> <span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Situs yang akan di crawl</span>
&nbsp;
<span style="color: #000088;">$rs</span> <span style="color: #339933;">=</span> scanPage<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span> 
<span style="color: #666666; font-style: italic;">/* 
* Pada tahap ini telah dilakukan pengambilan seluruh 
* konten dan teknik crawling telah dilakukan 
*/</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Memilah isi konten untuk diambil hanya isi yang mengandung tautan saja</span>
<span style="color: #666666; font-style: italic;">// Menggunakan regular expression (info selanjutnya klik di www.php.net :D ) </span>
<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/&lt;a(?:[^&gt;]*)href=&quot;(.*?)&quot;(?:[^&gt;]*)&gt;(.*?)&lt;\/a&gt;/is'</span><span style="color: #339933;">,</span><span style="color: #000088;">$rs</span><span style="color: #339933;">,</span><span style="color: #000088;">$output</span><span style="color: #339933;">,</span>PREG_SET_ORDER<span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Menampilkan hasil</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p style="text-align: justify;">Semoga bermanfaat.</p>
<blockquote>
<p style="text-align: justify;"><strong><em>Referensi :</em></strong><br />
Manning, Raghavan, and Schutze. 2008. <em>Introduction to Information Retrieval</em>. Cambridge University Press, New York.</p></blockquote>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://delicious.com/post?url=http://kohaci.com/2009/01/02/web-crawling.html&amp;title=Web+Crawling" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://kohaci.com/2009/01/02/web-crawling.html&amp;t=Web+Crawling" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Web+Crawling+-+http://b2l.me/cbek3+&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://kohaci.com/2009/01/02/web-crawling.html/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://kohaci.com/2009/01/02/web-crawling.html&amp;n=Web+Crawling&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://kohaci.com/2009/01/02/web-crawling.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Image Resizing di PHP CodeIgniter</title>
		<link>http://kohaci.com/2008/12/14/image-resizing-di-php-codeigniter.html</link>
		<comments>http://kohaci.com/2008/12/14/image-resizing-di-php-codeigniter.html#comments</comments>
		<pubDate>Sun, 14 Dec 2008 10:53:58 +0000</pubDate>
		<dc:creator>kohaci</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming-Q]]></category>

		<guid isPermaLink="false">http://kohaci.com/?p=132</guid>
		<description><![CDATA[Pada tulisan kali ini akan diberikan contoh kode tentang bagaimana cara membuat sistem upload gambar dimana saat proses penyimpanan gambar ke sistem juga dilakukan proses modifikasi ukuran gambar ke medium dan thumbnail. Menggunakan framework PHP CodeIgniter dengan Library PHP yang digunakan adalah GD2.  
Berikut struktur direktori khusus untuk upload gambar (optional) :

   [...]]]></description>
			<content:encoded><![CDATA[<p>Pada tulisan kali ini akan diberikan contoh kode tentang bagaimana cara membuat sistem <em>upload</em> gambar dimana saat proses penyimpanan gambar ke sistem juga dilakukan proses modifikasi ukuran gambar ke medium dan thumbnail. Menggunakan <em>framework</em> PHP CodeIgniter dengan Library PHP yang digunakan adalah GD2.  </p>
<p>Berikut struktur direktori khusus untuk <em>upload</em> gambar (<em>optional</em>) :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">        uploads<span style="color: #339933;">/</span>
              real<span style="color: #339933;">/</span>
              medium<span style="color: #339933;">/</span>
              thumbnail<span style="color: #339933;">/</span></pre></div></div>

<p>Direktori &#8220;real&#8221; untuk menyimpan gambar dengan ukuran sebenarnya, &#8220;medium&#8221; dan &#8220;thumbnail&#8221; untuk menyimpan gambar yang telah mengalami proses <em>resizing</em> ke ukuran medium dan thumbnail.<span id="more-132"></span></p>
<p>Langkah pertama, membuat <em>form upload</em> dengan nama file <strong>upload_form.php</strong> di View.</p>
<p>Sumber kode :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Upload Form&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> form_open_multipart<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'upload/do_upload'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;input type=&quot;file&quot; name=&quot;photo&quot; size=&quot;20&quot; /&gt;
&nbsp;
&lt;br /&gt;&lt;br /&gt;
&nbsp;
&lt;input type=&quot;submit&quot; value=&quot;upload&quot; /&gt;
&nbsp;
&lt;/form&gt;
&nbsp;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>Langkah terakhir, membuat proses penyimpanan gambar dan <em>resizing</em> di Controller, dengan nama file : <strong>upload.php </strong>.<strong> </strong></p>
<p>Sumber kode :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Upload Class
 *
 * @subpackage	Controller
 * @link        http://www.kohaci.com/
 * @author	Freddy Yuswanto (freddy@lenteravision.com)
 */</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Upload <span style="color: #000000; font-weight: bold;">extends</span> Controller <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span>  __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        parent<span style="color: #339933;">::</span><span style="color: #004000;">Controller</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'form'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'upload_form'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> do_upload<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'upload_path'</span><span style="color: #009900;">&#93;</span>	<span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;./uploads/real/&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'allowed_types'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">'gif|jpg|png|jpeg'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max_size'</span><span style="color: #009900;">&#93;</span>     <span style="color: #339933;">=</span> <span style="color: #0000ff;">'2000'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max_width'</span><span style="color: #009900;">&#93;</span>  	<span style="color: #339933;">=</span> <span style="color: #0000ff;">'2000'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max_height'</span><span style="color: #009900;">&#93;</span>  	<span style="color: #339933;">=</span> <span style="color: #0000ff;">'2000'</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'upload'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">upload</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">do_upload</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;photo&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$data</span>	 	<span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">upload</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">/* PATH */</span>
            <span style="color: #000088;">$source</span>             <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;./uploads/real/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file_name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">;</span>
            <span style="color: #000088;">$destination_thumb</span>	<span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;./uploads/thumbnail/&quot;</span> <span style="color: #339933;">;</span>
            <span style="color: #000088;">$destination_medium</span>	<span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;./uploads/medium/&quot;</span> <span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// Permission Configuration</span>
            <span style="color: #990000;">chmod</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source</span><span style="color: #339933;">,</span> <span style="color: #208080;">0777</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">/* Resizing Processing */</span>
	    <span style="color: #666666; font-style: italic;">// Configuration Of Image Manipulation :: Static</span>
	    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'image_lib'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
	    <span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image_library'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'GD2'</span><span style="color: #339933;">;</span>
	    <span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'create_thumb'</span><span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
	    <span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'maintain_ratio'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">/// Limit Width Resize</span>
            <span style="color: #000088;">$limit_medium</span>   <span style="color: #339933;">=</span> <span style="color: #cc66cc;">200</span> <span style="color: #339933;">;</span>
            <span style="color: #000088;">$limit_thumb</span>    <span style="color: #339933;">=</span> <span style="color: #cc66cc;">90</span> <span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// Size Image Limit was using (LIMIT TOP)</span>
            <span style="color: #000088;">$limit_use</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image_width'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image_height'</span><span style="color: #009900;">&#93;</span> ? <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image_width'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image_height'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// Percentase Resize</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit_use</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$limit_medium</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$limit_use</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$limit_thumb</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$percent_medium</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$limit_medium</span><span style="color: #339933;">/</span><span style="color: #000088;">$limit_use</span> <span style="color: #339933;">;</span>
                <span style="color: #000088;">$percent_thumb</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$limit_thumb</span><span style="color: #339933;">/</span><span style="color: #000088;">$limit_use</span> <span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">//// Making THUMBNAIL ///////</span>
	    <span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'width'</span><span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$limit_use</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$limit_thumb</span> ?  <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image_width'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$percent_thumb</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image_width'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">;</span>
            <span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'height'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$limit_use</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$limit_thumb</span> ?  <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image_height'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$percent_thumb</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image_height'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// Configuration Of Image Manipulation :: Dynamic</span>
            <span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'thumb_marker'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'_thumb-'</span><span style="color: #339933;">.</span><span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'width'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'x'</span><span style="color: #339933;">.</span><span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'height'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
            <span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'quality'</span><span style="color: #009900;">&#93;</span>      <span style="color: #339933;">=</span> <span style="color: #0000ff;">'100%'</span> <span style="color: #339933;">;</span>
            <span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'source_image'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$source</span> <span style="color: #339933;">;</span>
            <span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'new_image'</span><span style="color: #009900;">&#93;</span>    <span style="color: #339933;">=</span> <span style="color: #000088;">$destination_thumb</span> <span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// Do Resizing</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">image_lib</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">initialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">image_lib</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">resize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">image_lib</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">////// Making MEDIUM /////////////</span>
            <span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'width'</span><span style="color: #009900;">&#93;</span>   <span style="color: #339933;">=</span> <span style="color: #000088;">$limit_use</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$limit_medium</span> ?  <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image_width'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$percent_medium</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image_width'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">;</span>
            <span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'height'</span><span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$limit_use</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$limit_medium</span> ?  <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image_height'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$percent_medium</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image_height'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// Configuration Of Image Manipulation :: Dynamic</span>
            <span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'thumb_marker'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'_medium-'</span><span style="color: #339933;">.</span><span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'width'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'x'</span><span style="color: #339933;">.</span><span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'height'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
            <span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'quality'</span><span style="color: #009900;">&#93;</span>      <span style="color: #339933;">=</span> <span style="color: #0000ff;">'100%'</span> <span style="color: #339933;">;</span>
            <span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'source_image'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$source</span> <span style="color: #339933;">;</span>
            <span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'new_image'</span><span style="color: #009900;">&#93;</span>    <span style="color: #339933;">=</span> <span style="color: #000088;">$destination_medium</span> <span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// Do Resizing</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">image_lib</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">initialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">image_lib</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">resize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">image_lib</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Failed!&quot;</span> <span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Contoh hasil :</p>
<div class="wp-caption alignleft" style="width: 270px"><img title="Suzuki Airi - Clear :: Wait Me, I'll go to Japan !" src="http://kohaci.com/wp-content/uploads/2008/12/airi-suzuki.jpg" alt="I Love You. Ill go to Japan! Wait Me ..." width="260" height="389" align="middle" /><p class="wp-caption-text">Ukuran Asli : 260 x 389</p></div>
<div class="wp-caption alignleft" style="width: 143px"><img title="Airi Suzuki - Clear :: My dream is you ..." src="http://kohaci.com/wp-content/uploads/2008/12/airi-suzuki_medium-133x200.jpg" alt="Ukuran Medium :: 133 x 200" width="133" height="200" align="middle" /><p class="wp-caption-text">Ukuran Medium :: 133 x 200</p></div>
<div class="wp-caption alignleft" style="width: 70px"><img style="paddin-right : 30px;" title="Suzuki Airi - Clear :: Always U .." src="http://kohaci.com/wp-content/uploads/2008/12/airi-suzuki_thumb-60x90.jpg" alt="Ukuran Thumbnail :: 60 x 90" width="60" height="90" align="middle" /><p class="wp-caption-text">Ukuran Thumbnail :: 60 x 90</p></div>
<div style="clear : both;">&nbsp;</div>
<p><em><strong>Referensi :</strong></em><br />
<a href="http://www.codeigniter/user_guide/libraries/image_lib.html">http://www.codeigniter/user_guide/libraries/image_lib.html</a></p>
<blockquote><p><strong>Disclaimer :</strong></em><br />
Contoh gambar diambil dari Photo Album Suzuki Airi &#8211; Clear tanpa seizin dan pemberitahuan dari pihak penyedia pemegang lisensi photo/album. <em>Peace</em> <img src='http://kohaci.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p></blockquote>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://delicious.com/post?url=http://kohaci.com/2008/12/14/image-resizing-di-php-codeigniter.html&amp;title=%3Cem%3EImage+Resizing%3C%2Fem%3E+di+PHP+CodeIgniter" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://kohaci.com/2008/12/14/image-resizing-di-php-codeigniter.html&amp;t=%3Cem%3EImage+Resizing%3C%2Fem%3E+di+PHP+CodeIgniter" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=%3Cem%3EImage+Resizing%3C%2Fem%3E+di+PHP+CodeIgniter+-+http://b2l.me/cb23w+&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://kohaci.com/2008/12/14/image-resizing-di-php-codeigniter.html/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://kohaci.com/2008/12/14/image-resizing-di-php-codeigniter.html&amp;n=%3Cem%3EImage+Resizing%3C%2Fem%3E+di+PHP+CodeIgniter&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://kohaci.com/2008/12/14/image-resizing-di-php-codeigniter.html/feed</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Contoh Kode PHP untuk Highlight Phrase</title>
		<link>http://kohaci.com/2008/12/14/contoh-kode-php-untuk-highlight-phrase.html</link>
		<comments>http://kohaci.com/2008/12/14/contoh-kode-php-untuk-highlight-phrase.html#comments</comments>
		<pubDate>Sun, 14 Dec 2008 10:42:21 +0000</pubDate>
		<dc:creator>kohaci</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming-Q]]></category>

		<guid isPermaLink="false">http://kohaci.com/?p=130</guid>
		<description><![CDATA[Fungsi utama dari highlight phrase ini adalah memberi penebalan/pewarnaan/tanda tertentu pada masukan string tertentu terhadap suatu teks. Contoh :
Teks :
Ini Budi, Kakak sedang pergi ke pasar menemani Ibu berbelanja. Setelah itu Kakak pergi ke toko membantu Ayah. Sedangkan Ibu sebelum ke rumah, akan pergi mengambil titipan pesanan baju di rumah Ibu Andi.
Masukan string : Ibu
Hasil [...]]]></description>
			<content:encoded><![CDATA[<p>Fungsi utama dari <em>highlight phrase</em> ini adalah memberi penebalan/pewarnaan/tanda tertentu pada masukan <em>string</em> tertentu terhadap suatu teks. Contoh :</p>
<blockquote><p><strong>Teks :</strong></p>
<p>Ini Budi, Kakak sedang pergi ke pasar menemani Ibu berbelanja. Setelah itu Kakak pergi ke toko membantu Ayah. Sedangkan Ibu sebelum ke rumah, akan pergi mengambil titipan pesanan baju di rumah Ibu Andi.</p>
<p><strong>Masukan <em>string</em> :</strong> Ibu</p>
<p><strong>Hasil  :</strong></p>
<p>Ini Budi, Kakak sedang pergi ke pasar menemani <span style="color: #993300;">Ibu</span> berbelanja. Setelah itu Kakak pergi ke toko membantu Ayah. Sedangkan <span style="color: #993300;">Ibu</span> sebelum ke rumah, akan pergi mengambil titipan pesanan baju di rumah <span style="color: #993300;">Ibu</span> Andi.</p></blockquote>
<p>Pada contoh di atas masukan <em>string</em> yang ada di teks diberi penandaan berupa pewarnaan teks berupa warna merah.</p>
<p>Secara umum, <em>highlight phrase</em> ada dua metode. Agar lebih jelas berikut penerapannya di PHP.<span id="more-130"></span></p>
<p><strong>Metode 1 : Memberi penandaan sesuai dengan struktur masukan <em>string</em>.</strong></p>
<p>Sumber kode :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Highlight String :: All</span>
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/(&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">preg_quote</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;)/i&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;span style='color: #993300;'&gt;<span style="color: #000099; font-weight: bold;">\\</span>1&lt;/span&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Contoh :</p>
<blockquote><p><strong>Masukan <em>string</em> :</strong> Kakak sedang pergi</p>
<p><strong>Hasil :</strong></p>
<p>Ini Budi, <span style="color: #993300;">Kakak sedang pergi</span> ke pasar menemani Ibu berbelanja. Setelah itu Kakak pergi ke toko membantu Ayah. Sedangkan Ibu sebelum ke rumah, akan pergi mengambil titipan pesanan baju di rumah Ibu Andi.</p></blockquote>
<p><strong>Metode 2 : Memberi penandaan dengan  memecah masukan <em>string</em> menjadi per kata (bila lebih dari satu kata).</strong></p>
<p>Sumber kode :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Highlight String :: One By One</span>
<span style="color: #000000; font-weight: bold;">function</span> make_pattern<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Processing string be words</span>
    <span style="color: #000088;">$words</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/[\/\s<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\f</span>,:;=\'<span style="color: #000099; font-weight: bold;">\&quot;</span>$\&amp;\%+@`(.)-?!*]+/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Make pattern each words</span>
    <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$words</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$word</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$output</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/('</span><span style="color: #339933;">.</span><span style="color: #990000;">preg_quote</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$word</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">')/i'</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$output</span> <span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span>make_pattern<span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;span style='color: #993300;'&gt;<span style="color: #000099; font-weight: bold;">\\</span>1&lt;/span&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Contoh :</p>
<blockquote><p><strong>Inputan string :</strong> Kakak sedang pergi</p>
<p><strong>Hasil :</strong></p>
<p>Ini Budi, <span style="color: #993300;">Kakak</span> <span style="color: #993300;">sedang</span> <span style="color: #993300;">pergi</span> ke pasar menemani Ibu berbelanja. Setelah itu <span style="color: #993300;">Kakak</span> <span style="color: #993300;">pergi</span> ke toko membantu Ayah.<span style="color: #993300;"> Sedang</span>kan Ibu sebelum ke rumah, akan <span style="color: #993300;">pergi</span> mengambil titipan pesanan baju di rumah Ibu Andi.</p></blockquote>
<p><em><strong>Keterangan :</strong></em></p>
<p>Sebagian kode diambil dari fungsi <em>highlight_phrase()</em> bagian <a href="http://www.codeigniter.com/user_guide/helpers/text_helper.html">Text Helper di CodeIgniter</a>.</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://delicious.com/post?url=http://kohaci.com/2008/12/14/contoh-kode-php-untuk-highlight-phrase.html&amp;title=Contoh+Kode+PHP+untuk+%3Cem%3EHighlight+Phrase%3C%2Fem%3E" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://kohaci.com/2008/12/14/contoh-kode-php-untuk-highlight-phrase.html&amp;t=Contoh+Kode+PHP+untuk+%3Cem%3EHighlight+Phrase%3C%2Fem%3E" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Contoh+Kode+PHP+untuk+%3Cem%3EHighlight+Phrase%3C%2Fem%3E+-+http://b2l.me/cat3v+&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://kohaci.com/2008/12/14/contoh-kode-php-untuk-highlight-phrase.html/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://kohaci.com/2008/12/14/contoh-kode-php-untuk-highlight-phrase.html&amp;n=Contoh+Kode+PHP+untuk+%3Cem%3EHighlight+Phrase%3C%2Fem%3E&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://kohaci.com/2008/12/14/contoh-kode-php-untuk-highlight-phrase.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Stored Procedure and Function</title>
		<link>http://kohaci.com/2008/11/12/stored-procedure-and-function.html</link>
		<comments>http://kohaci.com/2008/11/12/stored-procedure-and-function.html#comments</comments>
		<pubDate>Wed, 12 Nov 2008 11:50:36 +0000</pubDate>
		<dc:creator>kohaci</dc:creator>
				<category><![CDATA[IT-Q]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming-Q]]></category>

		<guid isPermaLink="false">http://kohaci.com/?p=126</guid>
		<description><![CDATA[Function di MySQL
Dimisalkan gw punya database dengan salah satu nama tabelnya adalah &#8220;provinsi&#8221;, dengan isi tabelnya adalah :



kode_prov
nama_prov


11
NANGGROE ACEH DARUSSALAM


12
SUMATERA UTARA


13
SUMATERA BARAT


14
RIAU


15
JAMBI



Dengan dibantu bahasa pemrograman basis web (contoh di artikel ini memakai PHP) , ingin ditampilkan di browser keseluruhan tampilan isi tabel provinsi dari database (contoh di artikel ini memakai MySQL) dengan format tampilan berupa [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Function di MySQL</strong></p>
<p>Dimisalkan gw punya database dengan salah satu nama tabelnya adalah &#8220;provinsi&#8221;, dengan isi tabelnya adalah :</p>
<table border="0" align="center">
<tbody>
<tr>
<td style="border : 1px dashed #000">kode_prov</td>
<td style="border : 1px dashed #000">nama_prov</td>
</tr>
<tr>
<td style="border : 1px dashed #000">11</td>
<td style="border : 1px dashed #000">NANGGROE ACEH DARUSSALAM</td>
</tr>
<tr>
<td style="border : 1px dashed #000">12</td>
<td style="border : 1px dashed #000">SUMATERA UTARA</td>
</tr>
<tr>
<td style="border : 1px dashed #000">13</td>
<td style="border : 1px dashed #000">SUMATERA BARAT</td>
</tr>
<tr>
<td style="border : 1px dashed #000">14</td>
<td style="border : 1px dashed #000">RIAU</td>
</tr>
<tr>
<td style="border : 1px dashed #000">15</td>
<td style="border : 1px dashed #000">JAMBI</td>
</tr>
</tbody>
</table>
<p>Dengan dibantu bahasa pemrograman basis web (contoh di artikel ini memakai PHP) , ingin ditampilkan di browser keseluruhan tampilan isi tabel provinsi dari database (contoh di artikel ini memakai MySQL) dengan format tampilan berupa tabel. Dengan header <span style="text-decoration: underline;">kode_prov</span> diganti dengan KODE PROVINSI dan <span style="text-decoration: underline;">nama_prov</span> diganti dengan NAMA PROVINSI. Ada beberapa macam cara untuk menampilkannya, secara garis besar gw ambil dengan 2 cara, yaitu :<span id="more-126"></span></p>
<p><strong>Metode klasik</strong>, yaitu hampir semua proses dilakukan oleh PHP dari pengaturan struktur hingga tampilannya, proses SQL hanya sebagai <em>query</em> pemanggilan seluruh isi dalam tabel.</p>
<p>Sumber kode (PHP) :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> classic<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$query</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'provinsi'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$table</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;table border='1'&gt;&quot;</span> <span style="color: #339933;">;</span>
        <span style="color: #000088;">$table</span>  <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;tr&gt;&lt;td&gt;KODE PROVINSI&lt;/td&gt;&lt;td&gt;NAMA PROVINSI&lt;/td&gt;&lt;/tr&gt;&quot;</span> <span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">result</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">AS</span> <span style="color: #000088;">$provinsi</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$table</span>  <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;tr&gt;&quot;</span> <span style="color: #339933;">;</span>
            <span style="color: #000088;">$table</span>  <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;td&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$provinsi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">kode_prov</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/td&gt;&quot;</span> <span style="color: #339933;">;</span>
            <span style="color: #000088;">$table</span>  <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;td&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$provinsi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">nama_prov</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/td&gt;&quot;</span> <span style="color: #339933;">;</span>
            <span style="color: #000088;">$table</span>  <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/tr&gt;&quot;</span> <span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$table</span>  <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/table&gt;&quot;</span> <span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$table</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Metode modern</strong>, yaitu proses dilakukan <em>query</em> SQL , dimana tidak hanya memanggil isi dalam tabel tapi juga ikut membangun struktur dan tampilan. PHP hanya bertindak sebagai perantara untuk kemudian diterima oleh browser. Metode ini biasanya melibatkan fitur yang ada dalam RDBMS, di antaranya adalah <em>stored procedure</em>, <em>function</em>, dan <em>triggers</em>. Pada artikel bagian pertama ini akan diberikan contoh tentang Metode Fungsi di MySQL.</p>
<p>Sumber kode (MySQL) :</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">DELIMITER $$
&nbsp;
<span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> <span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #993333; font-weight: bold;">EXISTS</span> table_provinsi $$
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> table_provinsi <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> RETURNS TEXT
BEGIN
	DECLARE done INT <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #cc66cc;">0</span> ;
	DECLARE table1<span style="color: #66cc66;">,</span> table2 TEXT ;
	DECLARE name<span style="color: #66cc66;">,</span> code VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span> ;
	DECLARE province CURSOR <span style="color: #993333; font-weight: bold;">FOR</span> <span style="color: #993333; font-weight: bold;">SELECT</span> nama_prov<span style="color: #66cc66;">,</span> kode_prov <span style="color: #993333; font-weight: bold;">FROM</span> provinsi ;  
	DECLARE CONTINUE HANDLER <span style="color: #993333; font-weight: bold;">FOR</span> SQLSTATE <span style="color: #ff0000;">'02000'</span> <span style="color: #993333; font-weight: bold;">SET</span> done <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span> ;
&nbsp;
	<span style="color: #993333; font-weight: bold;">SET</span> table1	<span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'&lt;table border=&quot;1&quot;&gt;&lt;tr&gt;&lt;td&gt;KODE PROVINSI&lt;/td&gt;&lt;td&gt;NAMA PROVINSI&lt;/td&gt;&lt;/tr&gt;'</span> ;
&nbsp;
	OPEN province ;
&nbsp;
	REPEAT 
		FETCH province <span style="color: #993333; font-weight: bold;">INTO</span> name<span style="color: #66cc66;">,</span> code ;
		<span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #993333; font-weight: bold;">NOT</span> done THEN
			<span style="color: #993333; font-weight: bold;">SET</span> table1	<span style="color: #66cc66;">=</span> CONCAT<span style="color: #66cc66;">&#40;</span>table1<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'&lt;tr&gt;&lt;td&gt;'</span><span style="color: #66cc66;">,</span>code<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'&lt;/td&gt;&lt;td&gt;'</span><span style="color: #66cc66;">,</span>name<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'&lt;/td&gt;&lt;/tr&gt;'</span><span style="color: #66cc66;">&#41;</span> ;
		END <span style="color: #993333; font-weight: bold;">IF</span> ;
	UNTIL DONE END REPEAT ;
&nbsp;
	CLOSE province ;
&nbsp;
	<span style="color: #993333; font-weight: bold;">SET</span> table2 <span style="color: #66cc66;">=</span> CONCAT<span style="color: #66cc66;">&#40;</span>table1<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'&lt;/table&gt;'</span><span style="color: #66cc66;">&#41;</span> ;
&nbsp;
	<span style="color: #993333; font-weight: bold;">RETURN</span> table2 ;
END$$
&nbsp;
DELIMITER ;</pre></div></div>

<p>Sumber kode (PHP) :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> modern<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$query</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT table_provinsi() AS tabel_provinsi&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$table</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">row</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$table</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tabel_provinsi</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Good Luck!</p>
<p>CMIIW.</p>
<blockquote><p><em><strong>Keterangan :</strong></em></p>
<p>Sumber kode PHP di atas dibangun menggunakan Framework CodeIgniter dan untuk mempelajari <em>stored procedure and function</em> di MySQL <strong>tidak mutlak</strong> harus mempelajari CodeIgniter.</p></blockquote>
<p><strong><em>Referensi :</em></strong><br />
MySQL 5.0 Reference Manual</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://delicious.com/post?url=http://kohaci.com/2008/11/12/stored-procedure-and-function.html&amp;title=Stored+Procedure+and+Function" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://kohaci.com/2008/11/12/stored-procedure-and-function.html&amp;t=Stored+Procedure+and+Function" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Stored+Procedure+and+Function+-+http://b2l.me/canwb+&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://kohaci.com/2008/11/12/stored-procedure-and-function.html/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://kohaci.com/2008/11/12/stored-procedure-and-function.html&amp;n=Stored+Procedure+and+Function&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://kohaci.com/2008/11/12/stored-procedure-and-function.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Membuat Fungsi Seperator</title>
		<link>http://kohaci.com/2008/08/20/membuat-fungsi-seperator.html</link>
		<comments>http://kohaci.com/2008/08/20/membuat-fungsi-seperator.html#comments</comments>
		<pubDate>Wed, 20 Aug 2008 05:10:18 +0000</pubDate>
		<dc:creator>kohaci</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming-Q]]></category>

		<guid isPermaLink="false">http://kohaci.com/?p=84</guid>
		<description><![CDATA[Berikut contoh sumber kode untuk fungsi separator (biasa digunakan untuk penjumlahan mata uang) :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
&#60;?php
&#160;
/**
 * Created by. Kohaci
 * link  : http://www.kohaci.com/
 * email : freddy(underscore)august(at)yahoo(dot)co(dot)id
*/
&#160;
function separator&#40;$num, $suffix = ''&#41; &#123;
&#160;
	$ina_format_number = number_format&#40;$num, 3, ',','.'&#41;;
	$result = str_replace&#40;',000',$suffix,$ina_format_number&#41; ;
&#160;
	return $result ;
&#125;
&#160;
// How To Use
$num   = &#34;2000000&#34; ;
&#160;
echo separator&#40;$num&#41; ; // output : 2.000.000
echo [...]]]></description>
			<content:encoded><![CDATA[<p>Berikut contoh sumber kode untuk fungsi separator (biasa digunakan untuk penjumlahan mata uang) :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Created by. Kohaci
 * link  : http://www.kohaci.com/
 * email : freddy(underscore)august(at)yahoo(dot)co(dot)id
*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> separator<span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span><span style="color: #339933;">,</span> <span style="color: #000088;">$suffix</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000088;">$ina_format_number</span> <span style="color: #339933;">=</span> <span style="color: #990000;">number_format</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">','</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">',000'</span><span style="color: #339933;">,</span><span style="color: #000088;">$suffix</span><span style="color: #339933;">,</span><span style="color: #000088;">$ina_format_number</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$result</span> <span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// How To Use</span>
<span style="color: #000088;">$num</span>   <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;2000000&quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> separator<span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// output : 2.000.000</span>
<span style="color: #b1b100;">echo</span> separator<span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span><span style="color: #339933;">,</span><span style="color: #0000ff;">',-'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// output : 2.000.000,- </span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Good Luck !! (^-^)/</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://delicious.com/post?url=http://kohaci.com/2008/08/20/membuat-fungsi-seperator.html&amp;title=Membuat+Fungsi+Seperator" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://kohaci.com/2008/08/20/membuat-fungsi-seperator.html&amp;t=Membuat+Fungsi+Seperator" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Membuat+Fungsi+Seperator+-+http://b2l.me/cbdrx+&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://kohaci.com/2008/08/20/membuat-fungsi-seperator.html/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://kohaci.com/2008/08/20/membuat-fungsi-seperator.html&amp;n=Membuat+Fungsi+Seperator&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://kohaci.com/2008/08/20/membuat-fungsi-seperator.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>FusionCharts + CodeIgniter</title>
		<link>http://kohaci.com/2008/08/20/fusioncharts-codeigniter.html</link>
		<comments>http://kohaci.com/2008/08/20/fusioncharts-codeigniter.html#comments</comments>
		<pubDate>Wed, 20 Aug 2008 05:06:49 +0000</pubDate>
		<dc:creator>kohaci</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming-Q]]></category>

		<guid isPermaLink="false">http://kohaci.com/?p=81</guid>
		<description><![CDATA[FusionCharts adalah komponen pemetaan dalam basis flash yang dapat digunakan untuk merender data dalam bentuk animasi grafik. Dengan basis Adobe Flash 8, FusionCharts dapat digunakan dengan berbagai macam bahasa scripting web seperti HTML, .NET, ASP, JSP, PHP, ColdFusion dan lain sebagainya, untuk menghasilkan chart yang interaktif dan powerfull. Menggunakan XML sebagai data interface-nya, FusionCharts mampu [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">FusionCharts adalah komponen pemetaan dalam basis flash yang dapat digunakan untuk merender data dalam bentuk animasi grafik. Dengan basis Adobe Flash 8, FusionCharts dapat digunakan dengan berbagai macam bahasa scripting web seperti HTML, .NET, ASP, JSP, PHP, ColdFusion dan lain sebagainya, untuk menghasilkan chart yang interaktif dan <em>powerfull</em>. Menggunakan XML sebagai data <em>interface</em>-nya, FusionCharts mampu menciptakan charts yang <em>compact</em>, <em>interaktif</em>, dan <em>visually-arresting</em>.</p>
<p style="text-align: justify;">Untuk lebih jelasnya tentang FusionCharts dapat diakses situs resminya di <a href="http://www.fusioncharts.com/">www.fusioncharts.com</a>.</p>
<p style="text-align: justify;">Berikut tata cara menggabungkan FusionCharts dengan CodeIgniter :<span id="more-81"></span></p>
<p style="text-align: justify;">Download CodeIgniter <a href="http://codeigniter.com/downloads/">di sini</a> (versi 1.5+) .</p>
<p style="text-align: justify;">Download FusionChart <a href="http://www.fusioncharts.com/Download.asp">di sini</a> (versi 2.+) .</p>
<p style="text-align: justify;">Ketik kode pemrograman berikut dan simpan ke folder CodeIgniter di :</p>
<blockquote>
<p style="padding-left: 30px; text-align: justify;"><strong>system</strong> -&gt; <strong>application</strong> -&gt;<strong>libraries</strong></p>
</blockquote>
<p style="text-align: justify;">dengan nama <strong>fusioncharts.php</strong></p>
<p style="text-align: justify;"><em>Code</em> :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'BASEPATH'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'No direct script access allowed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Page: FusionCharts.php</span>
<span style="color: #666666; font-style: italic;">// Author: InfoSoft Global (P) Ltd.</span>
<span style="color: #666666; font-style: italic;">// This page contains functions that can be used to render FusionCharts.</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Fusioncharts <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> encodeDataURL<span style="color: #009900;">&#40;</span><span style="color: #000088;">$strDataURL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$addNoCacheStr</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//Add the no-cache string if required</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$addNoCacheStr</span><span style="color: #339933;">==</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// We add ?FCCurrTime=xxyyzz</span>
            <span style="color: #666666; font-style: italic;">// If the dataURL already contains a ?, we add &amp;FCCurrTime=xxyyzz</span>
            <span style="color: #666666; font-style: italic;">// We replace : with _, as FusionCharts cannot handle : in URLs</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span>strDataURL<span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;?&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&lt;&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000088;">$strDataURL</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&amp;FCCurrTime=&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;H_i_s&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">else</span>
			<span style="color: #000088;">$strDataURL</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;?FCCurrTime=&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;H_i_s&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
	<span style="color: #666666; font-style: italic;">// URL Encode it</span>
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$strDataURL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> datePart<span style="color: #009900;">&#40;</span><span style="color: #000088;">$mask</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dateTimeStr</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #339933;">@</span><span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$datePt</span><span style="color: #339933;">,</span> <span style="color: #000088;">$timePt</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dateTimeStr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$arDatePt</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$datePt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$dataStr</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">// Ensure we have 3 parameters for the date</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arDatePt</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$year</span><span style="color: #339933;">,</span> <span style="color: #000088;">$month</span><span style="color: #339933;">,</span> <span style="color: #000088;">$day</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$arDatePt</span><span style="color: #339933;">;</span>
            <span style="color: #666666; font-style: italic;">// determine the request</span>
            <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$mask</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;m&quot;</span><span style="color: #339933;">:</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$month</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;d&quot;</span><span style="color: #339933;">:</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$day</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;y&quot;</span><span style="color: #339933;">:</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$year</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #666666; font-style: italic;">// default to mm/dd/yyyy</span>
            <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$month</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$day</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$year</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$dataStr</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> renderChart<span style="color: #009900;">&#40;</span><span style="color: #000088;">$chartSWF</span><span style="color: #339933;">,</span> <span style="color: #000088;">$strURL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$strXML</span><span style="color: #339933;">,</span> <span style="color: #000088;">$chartId</span><span style="color: #339933;">,</span> <span style="color: #000088;">$chartWidth</span><span style="color: #339933;">,</span> <span style="color: #000088;">$chartHeight</span><span style="color: #339933;">,</span> <span style="color: #000088;">$debugMode</span><span style="color: #339933;">,</span> <span style="color: #000088;">$registerWithJS</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$strXML</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #000088;">$tempData</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;//Set the dataURL of the chart<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>chart_<span style="color: #006699; font-weight: bold;">$chartId</span>.setDataURL(<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$strURL</span><span style="color: #000099; font-weight: bold;">\&quot;</span>)&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">else</span>
            <span style="color: #000088;">$tempData</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;//Provide entire XML data using dataXML method<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>chart_<span style="color: #006699; font-weight: bold;">$chartId</span>.setDataXML(<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$strXML</span><span style="color: #000099; font-weight: bold;">\&quot;</span>)&quot;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Set up necessary variables for the RENDERCAHRT</span>
        <span style="color: #000088;">$chartIdDiv</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$chartId</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;Div&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$ndebugMode</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">boolToNum</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$debugMode</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$nregisterWithJS</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">boolToNum</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$registerWithJS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// create a string for outputting by the caller</span>
        <span style="color: #000088;">$render_chart</span> <span style="color: #339933;">=</span> <span style="color: #0000cc; font-style: italic;">&lt;&lt;&lt;RENDERCHART
&nbsp;
                        &lt;!-- START Script Block for Chart $chartId --&gt;
                        &lt;div id=&quot;$chartIdDiv&quot; align=&quot;center&quot;&gt;
                              Chart.
                      &lt;/div&gt;
                      &lt;script type=&quot;text/javascript&quot;&gt;	
                          //Instantiate the Chart	
                          var chart_$chartId = new FusionCharts(&quot;$chartSWF&quot;, &quot;$chartId&quot;, &quot;$chartWidth&quot;, &quot;$chartHeight&quot;, &quot;$ndebugMode&quot;, &quot;$nregisterWithJS&quot;);
                          $tempData
                          //Finally, render the chart.
                          chart_$chartId.render(&quot;$chartIdDiv&quot;);
                      &lt;/script&gt;	
                      &lt;!-- END Script Block for Chart $chartId --&gt;
RENDERCHART</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$render_chart</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> renderChartHTML<span style="color: #009900;">&#40;</span><span style="color: #000088;">$chartSWF</span><span style="color: #339933;">,</span> <span style="color: #000088;">$strURL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$strXML</span><span style="color: #339933;">,</span> <span style="color: #000088;">$chartId</span><span style="color: #339933;">,</span> <span style="color: #000088;">$chartWidth</span><span style="color: #339933;">,</span> <span style="color: #000088;">$chartHeight</span><span style="color: #339933;">,</span> <span style="color: #000088;">$debugMode</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// Generate the FlashVars string based on whether dataURL has been provided</span>
        <span style="color: #666666; font-style: italic;">// or dataXML.</span>
        <span style="color: #000088;">$strFlashVars</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&amp;chartWidth=&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$chartWidth</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&amp;chartHeight=&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$chartHeight</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&amp;debugMode=&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">boolToNum</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$debugMode</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$strXML</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #666666; font-style: italic;">// DataURL Mode</span>
            <span style="color: #000088;">$strFlashVars</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&amp;dataURL=&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$strURL</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">else</span>
            <span style="color: #666666; font-style: italic;">//DataXML Mode</span>
            <span style="color: #000088;">$strFlashVars</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&amp;dataXML=&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$strXML</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$HTML_chart</span> <span style="color: #339933;">=</span> <span style="color: #0000cc; font-style: italic;">&lt;&lt;&lt;HTMLCHART
                      &lt;!-- START Code Block for Chart $chartId --&gt;
                         &lt;object classid=&quot;clsid:d27cdb6e-ae6d-11cf-96b8-444553540000&quot; codebase=&quot;http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0&quot; width=&quot;$chartWidth&quot; height=&quot;$chartHeight&quot; id=&quot;$chartId&quot;&gt;
                            &lt;param name=&quot;allowScriptAccess&quot; value=&quot;always&quot; /&gt;
                            &lt;param name=&quot;movie&quot; value=&quot;$chartSWF&quot;/&gt;		
                            &lt;param name=&quot;FlashVars&quot; value=&quot;$strFlashVars&quot; /&gt;
                            &lt;param name=&quot;quality&quot; value=&quot;high&quot; /&gt;
                            &lt;embed src=&quot;$chartSWF&quot; FlashVars=&quot;$strFlashVars&quot; quality=&quot;high&quot; width=&quot;$chartWidth&quot; height=&quot;$chartHeight&quot; name=&quot;$chartId&quot; allowScriptAccess=&quot;always&quot; type=&quot;application/x-shockwave-flash&quot; pluginspage=&quot;http://www.macromedia.com/go/getflashplayer&quot; /&gt;
                          &lt;/object&gt;
                          &lt;!-- END Code Block for Chart $chartId --&gt; 
HTMLCHART</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$HTML_chart</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// boolToNum function converts boolean values to numeric (1/0)</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> boolToNum<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bVal</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$bVal</span><span style="color: #339933;">==</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> ? <span style="color: #cc66cc;">1</span> <span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setDataXML<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arrData</span><span style="color: #339933;">,</span><span style="color: #000088;">$caption</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #000088;">$numberPrefix</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$strXML</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;chart caption='&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$caption</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;' numberPrefix='&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$numberPrefix</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;' formatNumberScale='0'&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//Convert data to XML and append</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$arrData</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$arSubData</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000088;">$strXML</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;set label='&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$arSubData</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;' value='&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$arSubData</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;' /&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Close &lt;chart&gt; element</span>
	<span style="color: #000088;">$strXML</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/chart&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$strXML</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p style="text-align: justify;">
<p style="text-align: justify;">Kode di atas diambil dari hasil <em>extract</em> unduhan FusionChart yang diambil dari folder :</p>
<blockquote>
<p style="padding-left: 30px; text-align: justify;"><strong>Code</strong> -&gt; <strong>php</strong> -&gt; <strong>Includes</strong> -&gt; <strong>FusionCharts.php</strong></p>
</blockquote>
<p style="text-align: justify;">dengan beberapa modifikasi yang telah disesuaikan.</p>
<p style="text-align: justify;">Ambil beberapa file penting di FusionCharts, di antaranya :</p>
<blockquote>
<p style="padding-left: 30px; text-align: justify;"><strong>Code -&gt; FusionCharts</strong> -&gt; <strong>FusionCharts.js </strong></p>
<p style="padding-left: 30px; text-align: justify;"><strong>Code -&gt; FusionCharts</strong> -&gt; <strong>*.swf</strong></p>
</blockquote>
<p style="text-align: justify;">Simpan yang <strong>*.js</strong> ke folder CodeIgniter :</p>
<blockquote>
<p style="padding-left: 30px; text-align: justify;"><strong>public</strong> -&gt; <strong>javascripts</strong></p>
</blockquote>
<p style="text-align: justify;">Simpan yang <strong>*.swf</strong> ke folder CodeIgniter :</p>
<blockquote>
<p style="padding-left: 30px; text-align: justify;"><strong>public</strong> -&gt; <strong>flash</strong></p>
</blockquote>
<p style="text-align: justify;"><em>Jika tidak ada folder-folder tersebut di CodeIgniter maka buatlah sendiri folder-folder tersebut.</em></p>
<p style="text-align: justify;">Ketik kode berikut pada <em>view</em> dan simpan dengan nama <strong>charts.php</strong>.</p>
<p style="text-align: justify;"><em>Code</em> :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;&lt;!-- FUSION CHARTS --&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?=</span>base_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>public/javascripts/FusionCharts.js&quot;&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span>
            <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$graph</span> <span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p style="text-align: justify;">
<p style="text-align: justify;">Terakhir, ketik kode berikut pada <em>controller</em> dengan nama <strong>tes.php.</strong></p>
<p style="text-align: justify;"><em>Code</em> :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">class</span> Tes <span style="color: #000000; font-weight: bold;">extends</span> Controller <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$swfCharts</span> <span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            parent<span style="color: #339933;">::</span><span style="color: #004000;">Controller</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'fusioncharts'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">swfCharts</span>  <span style="color: #339933;">=</span> base_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'public/flash/Column3D.swf'</span> <span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">//Store Name of Products</span>
            <span style="color: #000088;">$arrData</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Product A&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$arrData</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Product B&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$arrData</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Product C&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$arrData</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Product D&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$arrData</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Product E&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$arrData</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Product F&quot;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">//Store sales data</span>
            <span style="color: #000088;">$arrData</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">567500</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$arrData</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">815300</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$arrData</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">556800</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$arrData</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">734500</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$arrData</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">676800</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$arrData</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">648500</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000088;">$strXML</span>        <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fusioncharts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setDataXML</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arrData</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Rp'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'graph'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fusioncharts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">renderChart</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">swfCharts</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #000088;">$strXML</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;productSales&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">600</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">300</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'charts'</span><span style="color: #339933;">,</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p style="text-align: justify;">
<p style="text-align: justify;">Jalankan. Dan jika benar maka <em>output</em> yang keluar di browser adalah sebagai berikut :</p>
<p style="text-align: center;"><a href="http://picasaweb.google.com/freddy.august/Blog_Only/photo#5236460346807991778"><img src="http://lh5.ggpht.com/freddy.august/SKuk8QPoveI/AAAAAAAABj4/-US73GC_zpQ/s400/fusion.jpg" /></a></p>
<p style="text-align: justify;">
<p style="text-align: justify;">Good Luck ! (^-^)/</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://delicious.com/post?url=http://kohaci.com/2008/08/20/fusioncharts-codeigniter.html&amp;title=FusionCharts+%2B+CodeIgniter" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://kohaci.com/2008/08/20/fusioncharts-codeigniter.html&amp;t=FusionCharts+%2B+CodeIgniter" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=FusionCharts+%2B+CodeIgniter+-+http://b2l.me/cbkg7+&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://kohaci.com/2008/08/20/fusioncharts-codeigniter.html/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://kohaci.com/2008/08/20/fusioncharts-codeigniter.html&amp;n=FusionCharts+%2B+CodeIgniter&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://kohaci.com/2008/08/20/fusioncharts-codeigniter.html/feed</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>
