<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Mohammad Emran Hasan - Latest Comments in Extended Model for CodeIgniter</title><link>http://phpfour.disqus.com/</link><description>This is Emran Hasan's blog for PHP, CSS, XHTML, JavaScript, Web 2.0, AJAX, Usability, and Web Standards related views, ideas, and sharing.</description><atom:link href="https://phpfour.disqus.com/extended_model_for_codeigniter_md_emran_hasan_phpfour/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 28 Oct 2010 18:50:12 -0000</lastBuildDate><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-591408528</link><description>&lt;p&gt;Hi there,&lt;/p&gt;&lt;p&gt;Great library- thank you sharing.  I'm having a bit of trouble though.  I'm getting duplicate entry errors when I try to save a model object.  It appears that it's trying to insert when it should update.  Here's the code in one of my custom libraries that uses an extended model:&lt;br&gt;&lt;code&gt;&lt;br&gt;$this-&amp;gt;CI-&amp;gt;load-&amp;gt;model('membership_model');&lt;br&gt;$membership = $this-&amp;gt;CI-&amp;gt;membership_model-&amp;gt;find("merchantId = '$merchantId' AND customerId = '$customerId'");&lt;br&gt;&lt;br&gt;if($membership) {  // this membership already exists&lt;br&gt;	$membership['points']++;&lt;br&gt;}&lt;br&gt;else {  // this is a new membership&lt;br&gt;	$this-&amp;gt;CI-&amp;gt;membership_model-&amp;gt;create();&lt;br&gt;	$membership['merchantId'] = $merchantId;&lt;br&gt;	$membership['customerId'] = $customerId;&lt;br&gt;	$membership['points'] = 1;&lt;br&gt;	$membership['created'] = date("Y-m-d H:i:s");&lt;br&gt;}&lt;br&gt;&lt;br&gt;$this-&amp;gt;CI-&amp;gt;membership_model-&amp;gt;save($membership);&lt;br&gt;...&lt;br&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;And this is the constructor for "membership_model.php":&lt;br&gt;&lt;code&gt;&lt;br&gt;function __construct() {&lt;br&gt;        // Call the Model constructor&lt;br&gt;        parent::__construct();&lt;br&gt;        $this-&amp;gt;loadTable('memberships');&lt;br&gt;        $this-&amp;gt;primaryKey = 'membershipId';&lt;br&gt;}&lt;br&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;What am I doing wrong here?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Steve N.</dc:creator><pubDate>Thu, 28 Oct 2010 18:50:12 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-591408516</link><description>&lt;p&gt;Hello,&lt;br&gt;very nice work,has anybody developed multi tables model using mysql views?&lt;/p&gt;&lt;p&gt;reneegate&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">reneegate</dc:creator><pubDate>Fri, 09 Jul 2010 01:25:09 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-6144170</link><description>&lt;p&gt;Thanks a lot~~&lt;br&gt;your extension save me lot of time! :)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">u3nu3n</dc:creator><pubDate>Tue, 10 Feb 2009 14:04:55 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-6088566</link><description>&lt;p&gt;Thanks Emran for this blog.Though Iam not a guru like some of you here,but i like the framework.&lt;br&gt;Iam a newbie to CI.Thanks again.&lt;/p&gt;&lt;p&gt;Abbas&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Abbas Mandal</dc:creator><pubDate>Sun, 08 Feb 2009 02:04:02 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-5684790</link><description>&lt;p&gt;The only way I could get this to work in Code Igniter 1.7.0 was to replace the Model.php in the system/libraries directory as the above methods didn't work for me.&lt;/p&gt;&lt;p&gt;This could be because I'm using Matchbox 0.9.4 which hasn't been updated to include a lot of the new code in Loader.php yet...&lt;/p&gt;&lt;p&gt;But apart from that, this is such a time saver and a brilliant piece of kit to add to your Code Igniter arsenal.&lt;/p&gt;&lt;p&gt;Thanks heaps for creating it and looking forward to seeing the additional features you've got planned.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">$1914876</dc:creator><pubDate>Fri, 30 Jan 2009 07:46:12 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-5267546</link><description>&lt;p&gt;Emran and others,&lt;br&gt;Thanks for the innovative work Emran. The comments also proved extremely helpful.&lt;/p&gt;&lt;p&gt;@Michael Wales: Extremely helpful and encouraging as always (esp. in the CI forums).&lt;/p&gt;&lt;p&gt;@Jacob &amp;amp; @stensi: Thanks for the additions.&lt;/p&gt;&lt;p&gt;@ryan &amp;amp; @joshdavey &amp;amp; @abe: Good call all around. To come on someone's forum and sound so arrogant shows a lack of taste, respect and manners.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Software_Miami</dc:creator><pubDate>Sun, 18 Jan 2009 12:52:09 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-5047317</link><description>&lt;p&gt;Why not using HMVC &amp;amp; Ignited Record &amp;amp; write a page module (like haughin' did) instead of hacking the core?&lt;br&gt;Saves even more time ^^&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Carlos</dc:creator><pubDate>Sat, 10 Jan 2009 15:32:25 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-4663535</link><description>&lt;p&gt;Forgive the personality analysis, but your seemingly irate attitude towards the author necessitated commentary.&lt;/p&gt;&lt;p&gt;Do bear in mind that you're a guest on this website, not an unpaid asshole.&lt;/p&gt;&lt;p&gt;Your message is true, but your delivery is definitely flawed. I'd recommend trying to be a little more polite, or you'll keep getting comments from people like Ryan. While I agree with what you said, the way you came across was pretty overwhelmingly full of douchebaggery. I have not personally visited the CakePHP forums but if they're full of people such as yourself who display a genuine "inability" to be polite, I don't plan on visiting anytime soon.&lt;/p&gt;&lt;p&gt;It is rather apparent that you're a CakePHP fan, but don't turn it into some form of irrational zeal. Step one would be to resist all caps. Step two would be to assume that other people aren't as brilliant as you, and don't have the MIT license memorised. Step three would be to perhaps quietly suggest that the author credit the source that shows definite similarity to his code snippets, instead of full-force attacking him.&lt;/p&gt;&lt;p&gt;Thanks for the info, Emran. I was trying to extend Model.php, and I eventually just popped a customised copy of "Model.php" in my APPPATH/libraries folder and overrode the default Model file altogether.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Abe</dc:creator><pubDate>Sat, 27 Dec 2008 04:26:27 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-6378167</link><description>&lt;p&gt;Forgive the personality analysis, but your seemingly irate attitude towards the author necessitated commentary.&lt;br&gt;&lt;br&gt;&lt;br&gt;Do bear in mind that you're a guest on this website, not an unpaid asshole.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Your message is true, but your delivery is definitely flawed. I'd recommend trying to be a little more polite, or you'll keep getting comments from people like Ryan. While I agree with what you said, the way you came across was pretty overwhelmingly full of douchebaggery. I have not personally visited the CakePHP forums but if they're full of people such as yourself who display a genuine "inability" to be polite, I don't plan on visiting anytime soon.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;It is rather apparent that you're a CakePHP fan, but don't turn it into some form of irrational zeal. Step one would be to resist all caps. Step two would be to assume that other people aren't as brilliant as you, and don't have the MIT license memorised. Step three would be to perhaps quietly suggest that the author credit the source that shows definite similarity to his code snippets, instead of full-force attacking him.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Thanks for the info, Emran. I was trying to extend Model.php, and I eventually just popped a customised copy of "Model.php" in my APPPATH/libraries folder and overrode the default Model file altogether.&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Abe</dc:creator><pubDate>Sat, 27 Dec 2008 04:26:27 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-6378166</link><description>&lt;p&gt;Thanks Jacob for pointing this out !!! I've been waiting for long to have CI support this. I will write a separate post with the update and a few additional features I planned long ago (probably post date: first week of Nov).&lt;br&gt;&lt;br&gt;&lt;br&gt;Everybody, please follow Jacob's two comments if you're using CodeIgniter 1.7.0.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Cheers!&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mohammad Emran Hasan</dc:creator><pubDate>Mon, 27 Oct 2008 15:49:33 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-3328727</link><description>&lt;p&gt;Thanks Jacob for pointing this out !!! I've been waiting for long to have CI support this. I will write a separate post with the update and a few additional features I planned long ago (probably post date: first week of Nov).&lt;/p&gt;&lt;p&gt;Everybody, please follow Jacob's two comments if you're using CodeIgniter 1.7.0.&lt;/p&gt;&lt;p&gt;Cheers!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mohammad Emran Hasan</dc:creator><pubDate>Mon, 27 Oct 2008 14:49:33 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-6378165</link><description>&lt;p&gt;Thanks for the reply, Emran! I hadn't seen your reply when I posted my fix below.&lt;br&gt;&lt;br&gt;&lt;br&gt;What I've done (in addition to the fix below) is rename it to MY_Model.php, placed it in system/application/libraries, updated the constructor to class MY_Model extends Model, and that's literally it. It's all working so far - I'll post back if I hit another snag :)&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;It may well be something they've fixed in these latest updates to CI, so you may wish to try it again, and if it works for, update your instructions accordingly.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Thanks for your contribution - it looks like it will be very useful!&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jacob Ball</dc:creator><pubDate>Mon, 27 Oct 2008 06:11:18 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-3321831</link><description>&lt;p&gt;Thanks for the reply, Emran! I hadn't seen your reply when I posted my fix below.&lt;/p&gt;&lt;p&gt;What I've done (in addition to the fix below) is rename it to MY_Model.php, placed it in system/application/libraries, updated the constructor to class MY_Model extends Model, and that's literally it. It's all working so far - I'll post back if I hit another snag :)&lt;/p&gt;&lt;p&gt;It may well be something they've fixed in these latest updates to CI, so you may wish to try it again, and if it works for, update your instructions accordingly.&lt;/p&gt;&lt;p&gt;Thanks for your contribution - it looks like it will be very useful!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jacob Ball</dc:creator><pubDate>Mon, 27 Oct 2008 05:11:18 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-6378163</link><description>&lt;p&gt;Well, as always after posting a 'help me!' question, I've worked it out.&lt;br&gt;&lt;br&gt;&lt;br&gt;Replace Line 196 of MY_Model.php:&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;$this-&amp;gt;fields = $this-&amp;gt;db-&amp;gt;field_names($table);&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;with&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;$this-&amp;gt;fields = $this-&amp;gt;db-&amp;gt;list_fields($table);&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;as field_names() is deprecated, and clearly in 1.7.0 does not work!!&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Hope this helps someone else :)&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jacob Ball</dc:creator><pubDate>Mon, 27 Oct 2008 00:30:36 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-6378162</link><description>&lt;p&gt;Michael's suggestion actually doesn't work, as I mentioned in my reply to him. You'll have to replace the actual Model.php in system/libraries to make it work. Hope this helps.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mohammad Emran Hasan</dc:creator><pubDate>Mon, 27 Oct 2008 00:23:27 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-6378161</link><description>&lt;p&gt;I'd like to try using this, and I've tried it using Michael's suggestion, eg renaming to MY_Model etc, but I keep getting this error:&lt;br&gt;&lt;br&gt;&lt;br&gt;Fatal error: Call to undefined method CI_DB_mysql_driver::field_names() in C:homecodeignitersystemapplicationlibrariesMY_Model.php on line 196&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;and I just can't work out how to get around it... any help would be great!&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jacob Ball</dc:creator><pubDate>Mon, 27 Oct 2008 00:02:19 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-3319092</link><description>&lt;p&gt;Well, as always after posting a 'help me!' question, I've worked it out.&lt;/p&gt;&lt;p&gt;Replace Line 196 of MY_Model.php:&lt;/p&gt;&lt;p&gt;$this-&amp;gt;fields = $this-&amp;gt;db-&amp;gt;field_names($table);&lt;/p&gt;&lt;p&gt;with&lt;/p&gt;&lt;p&gt;$this-&amp;gt;fields = $this-&amp;gt;db-&amp;gt;list_fields($table);&lt;/p&gt;&lt;p&gt;as field_names() is deprecated, and clearly in 1.7.0 does not work!!&lt;/p&gt;&lt;p&gt;Hope this helps someone else :)&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jacob Ball</dc:creator><pubDate>Sun, 26 Oct 2008 23:30:36 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-3319015</link><description>&lt;p&gt;Michael's suggestion actually doesn't work, as I mentioned in my reply to him. You'll have to replace the actual Model.php in system/libraries to make it work. Hope this helps.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mohammad Emran Hasan</dc:creator><pubDate>Sun, 26 Oct 2008 23:23:27 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-3317903</link><description>&lt;p&gt;I'd like to try using this, and I've tried it using Michael's suggestion, eg renaming to MY_Model etc, but I keep getting this error:&lt;/p&gt;&lt;p&gt;Fatal error: Call to undefined method CI_DB_mysql_driver::field_names() in C:\home\codeigniter\system\application\libraries\MY_Model.php on line 196&lt;/p&gt;&lt;p&gt;and I just can't work out how to get around it... any help would be great!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jacob Ball</dc:creator><pubDate>Sun, 26 Oct 2008 23:02:19 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-591408357</link><description>&lt;p&gt;Great work. It saves us a lot of time.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">haran</dc:creator><pubDate>Wed, 20 Aug 2008 15:20:10 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-6378155</link><description>&lt;p&gt;Great work. It saves us a lot of time.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">haran</dc:creator><pubDate>Wed, 20 Aug 2008 11:20:10 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-2839049</link><description>&lt;p&gt;Great work. It saves us a lot of time.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">haran</dc:creator><pubDate>Wed, 20 Aug 2008 11:20:10 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-591408412</link><description>&lt;p&gt;@joshdavey: why do a lot of people INSIST ON NOT READING before posting? Check the previous messages, this was SOLVED long ago.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mariano Iglesias</dc:creator><pubDate>Mon, 18 Aug 2008 19:40:02 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-591408417</link><description>&lt;p&gt;@Mariano Iglesias&lt;/p&gt;&lt;p&gt;You really want him to re-name "query(), "getNumRows()", "$this-&amp;gt;data" and other method/property names? These are standard method names used by pretty much every database abstraction layer in the history of programming.&lt;/p&gt;&lt;p&gt;Saying phpfour isn't respecting the MIT license is a bit harsh. He's just looking at other libraries for inspiration and building his own. Nothing wrong with that.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">joshdavey</dc:creator><pubDate>Mon, 18 Aug 2008 19:00:29 -0000</pubDate></item><item><title>Re: Extended Model for CodeIgniter</title><link>http://phpfour.com/extended-model-for-codeigniter/#comment-6378172</link><description>&lt;p&gt;@joshdavey: why do a lot of people INSIST ON NOT READING before posting? Check the previous messages, this was SOLVED long ago.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mariano Iglesias</dc:creator><pubDate>Mon, 18 Aug 2008 15:40:02 -0000</pubDate></item></channel></rss>