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

Class 'Model' not found - module development

Development and Programming

Oskar Smith's avatar
Oskar Smith
33 posts
16 years ago
Oskar Smith's avatar Oskar Smith

Hi all,

I would like to use a a Model in a module I’m developing for EE 2.0 and have run into a problem. I’ve got the model in the /third_party/my_module/models/ directory and calling it with;

$this->EE->load->model('my_model');

in my mcp.my_module.php file. It seems to find the model OK and attempts to load it but then fails with a PHP error;

Fatal error: Class 'Model' not found in /home/xxxx/public_html/system/expressionengine/third_party/my_module/models/my_model.php on line 3

My model is:

class My_model extends Model {

    function My_model()
    {
        parent::Model();
    }
}

Does anyone know what’s up here? Bug in EE or my code…?

Thanks in advance.

       
Oskar Smith's avatar
Oskar Smith
33 posts
16 years ago
Oskar Smith's avatar Oskar Smith

Ah, solved it. While I believe in CI you use Model, in EE you use CI_Model, so it should be;

class My_model extends CI_Model {

    function My_model()
    {
        parent::CI_Model();
    }
}

That now works fine.

       

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.