Welcome Guest, Not a member yet? Register   Sign In
Models in 3.0.6
#1

Hi,

I've been using CI for a number of years.

I'm upgrading all my sites to 3.0.6 and having problems with models.

Quote:Unable to locate the model you have specified: Blog

I'm even getting this message with the tutorial model

The model file name is blog_model.php

It is a copy of the "What is a Model" code from the tutorial.

It is being called from the Welcome controller with

Code:
public function test()
{
$this->load->model('blog');
}

Can someone confirm that 3.0.6 models are okay and/or point out where/if I am having one of those "moments"  Cool
Reply
#2

Wirh CI3, your class filenames (models, controllers & libraries) need to be UCfirst.
i.e. Blog_model instead of blog_model.
You would still load it with $this->load->model('blog_model');
Reply
#3

(04-27-2016, 01:37 AM)ciadmin Wrote: Wirh CI3, your class filenames (models, controllers & libraries) need to be UCfirst.
i.e. Blog_model instead of blog_model.
You would still load it with $this->load->model('blog_model');

Hi ciadmin,

Thanks for the reply. I am using UCfirst e.g.

PHP Code:
class Blog_model extends CI_Model {

 
       public $title;
 
       public $content;
 
       public $date;

 
       public function __construct()
 
       {
 
               // Call the CI_Model constructor
 
               parent::__construct();
 
       

Best regards,

Paul.
Reply
#4

What he is saying is that the models need to saved with UCFirst.

Blog_model.php
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(04-27-2016, 04:40 AM)InsiteFX Wrote: What he is saying is that the models need to saved with UCFirst.

Blog_model.php

Hi InsiteFX,

I've tried quite a few combinations of file names, class names and caller naming. Blog_model.php still results in :-

Quote:An uncaught Exception was encountered

Type: RuntimeException

Message: Unable to locate the model you have specified: Blog

Filename: /home/ubuntu/workspace/system/core/Loader.php

Line Number: 344


As it's only 3 files (including routes.php) would someone create a simple test with 3.0.6 and post the files here?  Blush  Angel
Reply
#6

(This post was last modified: 04-27-2016, 05:55 AM by Wouter60.)

If the model is named "Blog_model.php", then load it like this:
$this->load->model('blog_model');
So include the _model part, not just "blog".
And when you call a method that's part of the model, type this:
$this->blog_model->method_name();
Reply
#7

(04-27-2016, 05:54 AM)Wouter60 Wrote: If the model is named "Blog_model.php", then load it like this:
$this->load->model('blog_model');
So include the _model part, not just "blog".
And when you call a method that's part of the model, type this:
$this->blog_model->method_name();

Thank you Wouter60 and everyone else for your help.

I knew it was me - I just couldn't see the trees from the woods. Big Grin
Reply




Theme © iAndrew 2016 - Forum software by © MyBB