Module model doesn't work?

edited November 2012 in Bug Reports
Hi, I have a comment model, located in /module/guestbook/comment.php.

When I use this code in my controller:
$record = new $this->Comments_model;
echo $record->is_initialized(); // Returns TRUE

it says Fatal error: Class 'CI_Model' not found in C:\xampp\htdocs\fuel\fuel\application\core\MY_Model.php on line 35
What am I doing wrong?

Thanks in advance!

Comments

  • edited 1:41PM
    It doesn't look like your syntax is correct. Your model should be located in the fuel/modules/guestbook/models/comments_model.php. Then in your controller you would do the following:
    $this->load->module_model('guestbook', 'comments_model'); $record = $this->comments_model->create(); // then you can set values on the record like so: $record->name = 'My Name Goes here'; ... $record->save();
  • edited 1:41PM
    Yes, I do that, but I still get the same error:
    Fatal error: Class 'CI_Model' not found in C:\xampp\htdocs\fuel\fuel\application\core\MY_Model.php on line 35

    something else must be wrong?
  • edited 1:41PM
    Is this with a fresh install of the .93 or 1.0 branch?
  • edited 1:41PM
    .93
  • edited 1:41PM
    Strange because the model works in the dashboard, and I'm using the code you provided ...
  • edited 1:41PM
    Can you post the contents of the model and the URI path you are using in which you see the error.
Sign In or Register to comment.