<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: CodeIgniter model productivity methods</title>
	<link>http://pr0digy.com/codeigniter/model-productivity-methods/</link>
	<description>Web development with CodeIgniter and Mootools.</description>
	<pubDate>Wed, 19 Nov 2008 06:00:46 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
		<item>
		<title>By: Alex</title>
		<link>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-909</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Sat, 23 Aug 2008 09:42:07 +0000</pubDate>
		<guid>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-909</guid>
		<description>That's the nice thing about __autoload - you can create your own loading rules based upon class names.  Anyway, I'm glad you finally got it working :)</description>
		<content:encoded><![CDATA[<p>That&#8217;s the nice thing about __autoload - you can create your own loading rules based upon class names.  Anyway, I&#8217;m glad you finally got it working :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gillbates</title>
		<link>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-907</link>
		<dc:creator>gillbates</dc:creator>
		<pubDate>Sat, 23 Aug 2008 04:57:53 +0000</pubDate>
		<guid>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-907</guid>
		<description>and.. it works. Awesome!

So I modified the autoloader to only autoload classes with the prefix GILL_


function __autoload($class) {
	
	//only autoload classes containing GILL_
    if(stristr($class, 'GILL_')){
        require_once(PATH_TO_LIBRARIES.&#34;$class.php&#34;);
    }
}

Then I created GILL_MyModel.php in application/libraries containing the following class:

class GILL_MyModel extends Model 

Then my models are defined as such:

class Tourmodel extends GILL_MyModel {

class Subareamodel extends GILL_MyModel</description>
		<content:encoded><![CDATA[<p>and.. it works. Awesome!</p>
<p>So I modified the autoloader to only autoload classes with the prefix GILL_</p>
<p>function __autoload($class) {</p>
<p>	//only autoload classes containing GILL_<br />
    if(stristr($class, &#8216;GILL_&#8217;)){<br />
        require_once(PATH_TO_LIBRARIES.&quot;$class.php&quot;);<br />
    }<br />
}</p>
<p>Then I created GILL_MyModel.php in application/libraries containing the following class:</p>
<p>class GILL_MyModel extends Model </p>
<p>Then my models are defined as such:</p>
<p>class Tourmodel extends GILL_MyModel {</p>
<p>class Subareamodel extends GILL_MyModel</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gillbates</title>
		<link>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-906</link>
		<dc:creator>gillbates</dc:creator>
		<pubDate>Sat, 23 Aug 2008 04:44:06 +0000</pubDate>
		<guid>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-906</guid>
		<description>Bit of a problem with this... it's also trying to autoload Codeigniter's 'Model'. I suspect (and I have read of it somewhere) that the Model class does not start with CI. Maybe I should make my own prefix and only autoload files that begin with my prefix?</description>
		<content:encoded><![CDATA[<p>Bit of a problem with this&#8230; it&#8217;s also trying to autoload Codeigniter&#8217;s &#8216;Model&#8217;. I suspect (and I have read of it somewhere) that the Model class does not start with CI. Maybe I should make my own prefix and only autoload files that begin with my prefix?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gillbates</title>
		<link>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-903</link>
		<dc:creator>gillbates</dc:creator>
		<pubDate>Sat, 23 Aug 2008 02:41:19 +0000</pubDate>
		<guid>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-903</guid>
		<description>I wrapped the code in &lt;code&gt; and &lt;/code&gt; tags. That doesn't work, I suppose.

Still had a few snags when I was trying to make it work last night (until they dragged me away from the computer). I'll try to make it work today.</description>
		<content:encoded><![CDATA[<p>I wrapped the code in <code> and </code> tags. That doesn&#8217;t work, I suppose.</p>
<p>Still had a few snags when I was trying to make it work last night (until they dragged me away from the computer). I&#8217;ll try to make it work today.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-896</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Fri, 22 Aug 2008 15:01:07 +0000</pubDate>
		<guid>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-896</guid>
		<description>Did you encode that piece of code into HTML entities?

Yes, models should be created/written just as you suggested and then loaded in the standard CI way.</description>
		<content:encoded><![CDATA[<p>Did you encode that piece of code into HTML entities?</p>
<p>Yes, models should be created/written just as you suggested and then loaded in the standard CI way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gillbates</title>
		<link>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-895</link>
		<dc:creator>gillbates</dc:creator>
		<pubDate>Fri, 22 Aug 2008 14:05:27 +0000</pubDate>
		<guid>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-895</guid>
		<description>gah! I keep losing my code. Oh well. As you can probably guess, what I meant to say was I created a class named MyModel that extends Model in MyModel.php. Then Tourmodel extends MyModel. Is this the correct implementation?</description>
		<content:encoded><![CDATA[<p>gah! I keep losing my code. Oh well. As you can probably guess, what I meant to say was I created a class named MyModel that extends Model in MyModel.php. Then Tourmodel extends MyModel. Is this the correct implementation?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gillbates</title>
		<link>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-893</link>
		<dc:creator>gillbates</dc:creator>
		<pubDate>Fri, 22 Aug 2008 13:58:18 +0000</pubDate>
		<guid>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-893</guid>
		<description>hmm... so in my case, if I have a file named MyModel.php in system/application/libraries with the following:

&lt;code&gt;

&lt;/code&gt;

and after adding the autoload function in config, I should then define my models this way:

&lt;code&gt;
&#60;?php

if (!defined('BASEPATH')) exit('No direct script access allowed');

class Tourmodel extends MyModel {

function Tourmodel(){
  parent::__construct();
}
}
&lt;/code&gt;

Is this correct?</description>
		<content:encoded><![CDATA[<p>hmm&#8230; so in my case, if I have a file named MyModel.php in system/application/libraries with the following:</p>
<p><code></p>
<p></code></p>
<p>and after adding the autoload function in config, I should then define my models this way:</p>
<p><code><br />
&lt;?php</p>
<p>if (!defined('BASEPATH')) exit('No direct script access allowed');</p>
<p>class Tourmodel extends MyModel {</p>
<p>function Tourmodel(){<br />
  parent::__construct();<br />
}<br />
}<br />
</code></p>
<p>Is this correct?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-891</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Fri, 22 Aug 2008 12:32:45 +0000</pubDate>
		<guid>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-891</guid>
		<description>Gill, I really don't know why CodeIgniter does not allow to extend the core model...  Anyway, you can just create &lt;em&gt;MY_Model&lt;/em&gt; class and drop it into your &lt;em&gt;application/libraries&lt;/em&gt; folder.  Basically it should look something like this:

&lt;pre class="prettyprint"&gt;
&#60;?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class MY_Model extends Model {

	
	public function __construct(){
            parent::Model();
	}

        //add your own methods here
}

?&#62;
&lt;/pre&gt;

Once you've done that, read &lt;a href="http://pr0digy.com/codeigniter/loading-external-libraries/" rel="nofollow"&gt;this article&lt;/a&gt; - essentially it's a simple, yet very flexible way to load external resources (works only with PHP5).

Well, that's about it - I hope that helps :)</description>
		<content:encoded><![CDATA[<p>Gill, I really don&#8217;t know why CodeIgniter does not allow to extend the core model&#8230;  Anyway, you can just create <em>MY_Model</em> class and drop it into your <em>application/libraries</em> folder.  Basically it should look something like this:</p>
<pre class="prettyprint">
&lt;?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class MY_Model extends Model {

	public function __construct(){
            parent::Model();
	}

        //add your own methods here
}

?&gt;
</pre>
<p>Once you&#8217;ve done that, read <a href="http://pr0digy.com/codeigniter/loading-external-libraries/" rel="nofollow">this article</a> - essentially it&#8217;s a simple, yet very flexible way to load external resources (works only with PHP5).</p>
<p>Well, that&#8217;s about it - I hope that helps :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gillbates</title>
		<link>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-890</link>
		<dc:creator>gillbates</dc:creator>
		<pubDate>Fri, 22 Aug 2008 12:12:52 +0000</pubDate>
		<guid>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-890</guid>
		<description>Thanks for posting this. I have a question about the following:

&lt;em&gt;If you decide to use those in your code, the best place for them would be in a parent model.&lt;/em&gt;

How do I implement this?</description>
		<content:encoded><![CDATA[<p>Thanks for posting this. I have a question about the following:</p>
<p><em>If you decide to use those in your code, the best place for them would be in a parent model.</em></p>
<p>How do I implement this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ruben Zevallos Jr.</title>
		<link>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-826</link>
		<dc:creator>Ruben Zevallos Jr.</dc:creator>
		<pubDate>Mon, 30 Jun 2008 15:46:24 +0000</pubDate>
		<guid>http://pr0digy.com/codeigniter/model-productivity-methods/#comment-826</guid>
		<description>Well... nice post... your blog is giving me a lot of new ideas and clues about CI... thanks</description>
		<content:encoded><![CDATA[<p>Well&#8230; nice post&#8230; your blog is giving me a lot of new ideas and clues about CI&#8230; thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>
