We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

MY_Model in EE

Development and Programming

jcowen's avatar
jcowen
66 posts
12 years ago
jcowen's avatar jcowen

Hi All,

Could someone tell me whether I’m doing the wrong thing here. I’m trying to use this chap’s CRUD Model;

https://github.com/jamierumbelow/codeigniter-base-model

Is it only for codeigniter? I seem to be hitting all kinds of problems when trying to use in EE 2.4 If it does work, where is it meant to go in the filesystem?

Thanks in advance for any help

       
Boyink!'s avatar
Boyink!
5,011 posts
12 years ago
Boyink!'s avatar Boyink!

Yea, you wouldn’t use that in EE.

       
jcowen's avatar
jcowen
66 posts
12 years ago
jcowen's avatar jcowen

Ok, so I found a way to do this. It’s really very handy if you are making a module, despite comments from Boyink

First, plonk MY_Model into system/expressionengine/models - all lower case ‘my_model.php’

Then in system/expressionengine/config/autoload.php, make the following change;

$autoload['model'] = array('my_model');

In your third_party module models, simply extend MY_Model instead of CI_Model.

There you have it.

Make sure you specify a protected var of $_table which is of course your table name. There’s actually no need to even declare the constructor, simply the table, and maybe $return_type if you want to return all records as either objects or arrays. Now you’ve got standard CRUD methods to use across multiple models.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.