• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
$this->load->model('Account'); doesn't work.. i had to use $this->load->model('Account_model');


I have a model which is account_model.php (Account_model) it is normal that i had to call it using :


in the help file it seem we can use only the model name but it give me an error saying it couldnt find it.


and i think i can't rename the model account.php otherwise it won't work.


// not

Hi there,

I tried your code but that doesn't change anything and btw ..


are working without problem with or without uppercase. Furthermore, that not the issue i was exposing.. you should read my post a bit more Tongue

If you look at the help file.. it tell us that we can load our models by using..

while having as model filename account_model.php

but that doesn't work. I get this error.

An Error Was Encountered

Unable to locate the model you have specified: account

I was just wondering if it was a bug or not.


File name must start with a uppercase character and continue with lowercase chars till the end.
Example: Account_model.php
Class definition in the file should be the same.
Example: class Account_model extends CI_Model{}
Loading of model is done in lowercase.
Example: $this->load->model('account_model'); $this->account_model->whatever();

Got it ?

L.E: i bet you are developing under windows right now.
You will have big surprises when you will go live with your site on a linux machine if you don't respect the file name / class name / load class convention .

[eluser]Eric Barnes[/eluser]
I think you are wanting this:
$this->load->model(‘account_model’, 'account');

@twisted1919 : thanks for theses infos. However i think your wrong. Filename must be in lower case and class name must have the first letter capitalized. Loading the model is same as class name (capitalized first letter and rest lower case) however that what the user guide tell us. Anyone can confirm?

@Eric barn : yes that what i was looking for so thanks but this isnt said in the user guide so correct me if i am wrong ? The exemple saying load('Account') is also wrong since the model name must have _model.php in filename and it seem that calling the model without this won't work.

Would like to have some clarifications / explanations on what ive said above.


[eluser]Eric Barnes[/eluser]
It does not have to have _model in the file name. You could just use models/Account.php if you wanted. But most use _model or _m so that they do not have any class name collisions with controllers or other files.

Alright that good to know! Then i will simply use your suggestion as second parameter.


Quote:Where Model_name is the name of your class. Class names must have the first letter capitalized with the rest of the name lowercase. Make sure your class extends the base Model class.

The file name will be a lower case version of your class name. For example, if your class is this:

Not sure where you're seeing otherwise.

Yeah but the object name had nothing to do with filename ?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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