Welcome Guest, Not a member yet? Register   Sign In
Fatal error: Class 'Test_model' not found...
#1

[eluser]Gary the Llama[/eluser]
Brand new to CI and I've been going through the User Guide. Everything was great until I got to the Models section.

Here's my model code which is in application/models/test.php:

Code:
class test extends Model
{
    function test()
    {
        // Call the Model constructor.
        parent::Model();
    }
}

I call it from application/controllers/mytest.php like so:

Code:
function index()
{
       $this->load->database();
       $this->load->model('test');

}

And when I go to the page I get this error:

Fatal error: Class 'test' not found in /nfsn/content/garythellama/public/system/libraries/Loader.php on line 177

Any ideas? I saw that there were issues with the class names of your model so I've tried every possible variation and it hasn't made a difference.
#2

[eluser]Armchair Samurai[/eluser]
Direct from the User Guide:
Quote:Class names must have the first letter capitalized with the rest of the name lowercase.
Depending on what system you're running, text might be case sensitive - try capitalizing your class name and constructor.
#3

[eluser]Gary the Llama[/eluser]
Yeah, I've tried that too. No luck. Same error.
#4

[eluser]nirbhab[/eluser]
Use <?php ?> rather than <? ?>,
is there any directory or controller or library named test? I mean, is there any other class test in controller or owner library.

finally, try this:
Code:
class testing extends Model
{
    function testing()
    {
        // Call the Model constructor.
        parent::Model();
    }
}

//controller
function index()
{
       $this->load->database();
       $this->load->model('testing');

}
Hope your file named test/testing exists in Models directory and class name and filenames are same.
#5

[eluser]wiredesignz[/eluser]
The error suggests the loader has found and loaded the test.php file, but it can't find the class.
Code:
//CI_Loader.php line 173
require_once(APPPATH.'models/'.$path.$model.EXT);

$model = ucfirst($model);
                
$CI->$name = new $model();    //<--- line 177
#6

[eluser]Gary the Llama[/eluser]
Well, I'm just retarded. I hadn't put my start (&lt;?php) and end (?&gtWink tags in my model file. I'm sure it's a classic newbie mistake. Sad
#7

[eluser]nirbhab[/eluser]
:-) some times it happens with senior members also...not a great issue...




Theme © iAndrew 2016 - Forum software by © MyBB