• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot find model class

#1
[eluser]Apidcloud[/eluser]
Hello everyone,

I've been trying to load a model for like 3 or 4 hours but I always get this error:
Quote:Fatal error: Class 'Site_model' not found in pathFromXamppProjectFolder\system\core\Loader.php on line 303

The model I'm trying to load is as follows (I believe that the constructor isn't needed):
Code:
<? php

class Site_model extends CI_Model {
    
    function __construct()
    {
        parent::__construct();
    }
    // more functions
}

The filename is site_model.php and it is placed inside models folder

In order to actually load it from my controller, I've tried the following - which raises the error mentioned above:
Code:
$this->load->model('site_model');

In case I'm using something deprecated inside my autoload file, I've just changed the following:
Code:
$autoload['libraries'] = array('database');
$autoload['helper'] = array('url', 'form');

It could, somehow, be related to the fact that I am not extending CI_Model into a new class placed inside core folder, which I'd then use to extend the model I really wanna use. Since I'm not entirely sure why it should, or not, go that way, I've decided to create a topic explaining the situation.

Thanks

#2
[eluser]gabybob[/eluser]
hello,

your file on disk should have a capitalized first letter eg Site_model.php

this is the new standard CI 3.0-dev

best to you

Gabriel

#3
[eluser]Apidcloud[/eluser]
I've tried to capitalize the first letter but it's still raising the same error

Thanks

#4
[eluser]gabybob[/eluser]
Apidcloud

CONNECTED you at [email protected]

#5
[eluser]gabybob[/eluser]
An Error Was Encountered

Unable to locate the model you have specified: Site_model

goodnight,

I just realized the test->

the file name begins with a lowercase -> error

attention to the mismanagement of the case (upperCase and lowercase) with windows

to avoid this kind of problem touner to LINUX

french trad
courage


bonsoir,

je viens de réaliser le test->

le nom du fichier commence par une minuscule -> erreur

attention à la mauvaise gestion de la casse ( upperCase and lowercase ) avec windows

pour échapper à ce genre de problème se touner vers LINUX

#6
[eluser]Apidcloud[/eluser]
I'm not sure I understand what you said, but are u saying that the filename should start with an uppercase instead? I already tried that as mentioned above but I still have the same error

#7
[eluser]InsiteFX[/eluser]
If you are running Xampp, it needs to be installed in the root directory of your hard drive. Not in a sub folder or the program files folder this is a bug in Xampp.


#8
[eluser]Apidcloud[/eluser]
I've installed it in the root though

#9
[eluser]Karman de Lange[/eluser]
If your running the Dev version (from github), then the model name must be uppercase first letter.

If you run the version from the normal downloads website, then model must be lowercase first letter.

Just security comment, make sure you include at the top of the model something like.

Code:
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

#10
[eluser]Apidcloud[/eluser]
which model name are you referring to? The one which extends CI_Model?
I've tried both lowercase and uppercase first letter but it's still throwing the same error

Thanks for the security condition Wink


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.