<?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>No Meaning Developer &#187; CodeIgniter</title>
	<atom:link href="http://kentreez.com/blog/tag/codeigniter/feed/" rel="self" type="application/rss+xml" />
	<link>http://kentreez.com/blog</link>
	<description>kentreez&#039;s blog</description>
	<lastBuildDate>Wed, 08 Sep 2010 16:21:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Matchbox 0.9.4 URI</title>
		<link>http://kentreez.com/blog/php/matchbox-094-uri/</link>
		<comments>http://kentreez.com/blog/php/matchbox-094-uri/#comments</comments>
		<pubDate>Tue, 22 Jul 2008 07:08:27 +0000</pubDate>
		<dc:creator>kentreez</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Rules & Conditions]]></category>

		<guid isPermaLink="false">http://journal.kentreez.com/?p=31</guid>
		<description><![CDATA[Matchbox Ref: http://code.google.com/p/matchbox/ ผมตั้งชื่อ Module กับชื่อ Controller ใน Module เป็นชื่อเดียวกันครับ ก็เลยเกิดข้อผิดพลาดในการ parse route ตอนแรกก็เข้าใจว่าเป็น Bug ของ Matchbox ครับ. แต่จริงๆ แล้วไม่ใช่ครับ เป็นความจงใจของ Zacharias Knudsen เค้าครับ มีกฎดังนี้ครับ www.example.com/module/controller/method/parameter The first segment represents the module in which the controller can be found. The second segment represents the controller that should be invoked. The third segment represents the method [...]]]></description>
			<content:encoded><![CDATA[<p>Matchbox Ref: <a href="http://code.google.com/p/matchbox/">http://code.google.com/p/matchbox/</a></p>
<p>ผมตั้งชื่อ Module กับชื่อ Controller ใน Module เป็นชื่อเดียวกันครับ  ก็เลยเกิดข้อผิดพลาดในการ parse route ตอนแรกก็เข้าใจว่าเป็น Bug ของ Matchbox ครับ. แต่จริงๆ แล้วไม่ใช่ครับ เป็นความจงใจของ Zacharias Knudsen เค้าครับ</p>
<p>มีกฎดังนี้ครับ<br />
<code>www.example.com/module/controller/method/parameter</code></p>
<ol>
<li>The first segment represents the module in which the controller can be found.</li>
<li>The second segment represents the controller that should be invoked.</li>
<li>The third segment represents the method that should be called.</li>
<li>The fourth, and any additional segments, represents the variables that will be passed to the controller.</li>
</ol>
<p>และมีเงื่อนไขดังนี้</p>
<ol>
<li>If the controller is located in a subfolder then the subfolder must be added as another segment between the module and controller segments.<br />
(ถ้า controller อยู่ใน subfolder ให้ใส่ subfolder ไปใน URI ด้วย ตรงระหว่าง module กับ controller อันนี้ค่อนข้าง make sence ครับ ไม่มีอะไรมาก)</li>
<li>If the controller have the same name as the module, the controller segment can be omitted.<br />
(<strong>ถ้า controller ชื่อเดียวกับ module ให้ละชื่อ controller</strong> ใน URI ครับ ก็จะกลายเปน www.example.com/module/method/parameter)</li>
<li>If the controller is in a subfolder and have the same name as the subfolder, the controller segment can be omitted.<br />
(<strong>ถ้า controller ชื่อเดียวกับ subfolder ให้ละชื่อ controller</strong> ใน URI )</li>
</ol>
<p>แล้วถ้า module, subfolder และ controller ชื่อเดียวกันหมดละ!?</p>
<p>อันนี้ผมทำการทดลองให้แล้วครับ ก็คือให้ละชื่อ controller เช่นเดิมครับ โดยจะต้องระบุ module และ subfolder ไว้ใน URI</p>
]]></content:encoded>
			<wfw:commentRss>http://kentreez.com/blog/php/matchbox-094-uri/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Codeigniter MY_Loader in PHP4</title>
		<link>http://kentreez.com/blog/php/codeigniter-my_loader-in-php4/</link>
		<comments>http://kentreez.com/blog/php/codeigniter-my_loader-in-php4/#comments</comments>
		<pubDate>Tue, 22 Jul 2008 05:05:36 +0000</pubDate>
		<dc:creator>kentreez</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Solutions]]></category>

		<guid isPermaLink="false">http://journal.kentreez.com/?p=24</guid>
		<description><![CDATA[ใน /system/codeigniter/CodeIgniter.php จะมีทางแยกระหว่าง php4 กับ php5 อยู่ ซึ่ง php4 จะโหลดคลาส Loader ขึ้นมาก่อนและโหลดคลาส CI_Base (ใน /system/codeigniter/Base4.php) ซึ่งจะสืบทอด (extends) จาก CI_Loader ตรงนี้จึงเป็นจุดบอดเวลาที่เราต้องการจะเขียนคลาส MY_Loader เพื่อใช้งาน เพราะ Base4 มันเขียนไว้ว่ายังไงก็จะสืบถอดจาก CI_Loader ให้ได้ซะอย่างงั้น ผมพยายามหาทางออก ที่จะไม่ต้องแก้ไขตัว Core ของ CodeIgniter แต่ก็จนปัญหาครับ. จริงๆ แล้วมันมีอยู่อีกแบบนึงคือ เขียน CI_Loader ขึ้นมาใหม่เองทั้งหมด (แบบที่ Matchbox ทำ) แล้ววางไว้ที่ /system/application/libraries/Loader.php แต่ก็ดูจะผิดจุดประสงค์ไปหน่อยครับ เพราะว่า MY_Loader ของผมต้องการจะต่อเติม หรือแก้ไขเฉพาะบาง method ที่อยู่ใน CI_Loaderเท่านั้น. สุดท้ายก็ต้องตัดสินใจแก้ที่ Core ของมันครับ ที่จะแก้คือไฟล์ /system/codeigniter/Base4.php [...]]]></description>
			<content:encoded><![CDATA[<p>ใน <em>/system/codeigniter/CodeIgniter.php</em> จะมีทางแยกระหว่าง php4 กับ php5 อยู่ ซึ่ง php4 จะโหลดคลาส Loader ขึ้นมาก่อนและโหลดคลาส CI_Base (ใน <em>/system/codeigniter/Base4.php</em>) ซึ่งจะสืบทอด (extends) จาก CI_Loader ตรงนี้จึงเป็นจุดบอดเวลาที่เราต้องการจะเขียนคลาส MY_Loader เพื่อใช้งาน เพราะ Base4 มันเขียนไว้ว่ายังไงก็จะสืบถอดจาก CI_Loader ให้ได้ซะอย่างงั้น</p>
<p>ผมพยายามหาทางออก ที่จะไม่ต้องแก้ไขตัว Core ของ CodeIgniter แต่ก็จนปัญหาครับ. จริงๆ แล้วมันมีอยู่อีกแบบนึงคือ เขียน CI_Loader ขึ้นมาใหม่เองทั้งหมด (แบบที่ Matchbox ทำ) แล้ววางไว้ที่ <em>/system/application/libraries/Loader.php</em> แต่ก็ดูจะผิดจุดประสงค์ไปหน่อยครับ เพราะว่า MY_Loader ของผมต้องการจะต่อเติม หรือแก้ไขเฉพาะบาง method ที่อยู่ใน CI_Loaderเท่านั้น.</p>
<p>สุดท้ายก็ต้องตัดสินใจแก้ที่ Core ของมันครับ ที่จะแก้คือไฟล์ <strong><em>/system/codeigniter/Base4.php</em></strong> ครับ</p>
<p>จากเดิม</p>
<pre>class CI_Base extends CI_Loader {
    function CI_Base()
    {
        // This allows syntax like $this-&gt;load-&gt;foo() to work
        parent::CI_Loader();
        $this-&gt;load =&amp; $this; // This allows resources used within controller constructors to work
        global $OBJ;
        $OBJ = $this-&gt;load; // Do NOT use a reference.
    }
}</pre>
<p>เปลี่ยนเป็น</p>
<pre><span style="color: #0000ff;">if (class_exists( config_item('subclass_prefix')."Loader" ))
{
    eval('
    class CI_Base extends '.config_item('subclass_prefix')."Loader".' {
        function CI_Base()
        {
            // This allows syntax like $this-&gt;load-&gt;foo() to work
            parent::'.config_item('subclass_prefix')."Loader".'();
            $this-&gt;load =&amp; $this; // This allows resources used within controller constructors to work
            global $OBJ;
            $OBJ = $this-&gt;load; // Do NOT use a reference.
        }
    }
    ');
}
else
{</span>
    class CI_Base extends CI_Loader {
        function CI_Base()
        {
            // This allows syntax like $this-&gt;load-&gt;foo() to work
            parent::CI_Loader();
            $this-&gt;load =&amp; $this; // This allows resources used within controller constructors to work
            global $OBJ;
            $OBJ = $this-&gt;load; // Do NOT use a reference.
        }
    }
<span style="color: #0000ff;">}</span></pre>
<p>แค่นี้ก็จะสามารถใช้งาน MY_Loader ได้แล้วล่ะครับ</p>
]]></content:encoded>
			<wfw:commentRss>http://kentreez.com/blog/php/codeigniter-my_loader-in-php4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
