Home > Uncategorized > CodeIgniter Unable to locate the model you have specified:

CodeIgniter Unable to locate the model you have specified:

In fact the problem is that code igniter does not deal with file name correctly.
If you use a filename in capital letter CI process it and convert the file name in lowercase. Thats why if you refer Mymodel.php instead of “MyModel.php” it will search “mymodel.php”. It results the file as unavailable.

like if you have this line in your controller and have a file named “Model_test.php” in models folder the file will not be accesable.

$this->load->model(‘Model_test’);

So, the file should be renamed as “model_test.php”
Hope it will work πŸ™‚

  1. Arup
    June 25, 2009 at 7:48 am

    NO, this is not the case.
    I have saved the model name HelloModel.php
    and have the following code in controller but it works fine.

    $this->load->model(‘HelloModel’);
    $this->HelloModel->selectData();

  2. prosuncsedu
    June 25, 2009 at 8:25 am

    Thanks Arup for the reply.
    But actually you are wrong.
    This is the way CI handles URL.
    YOu can check CodeIgniter.php or Router.php and some other related file to be sure of it.
    πŸ™‚

  3. August 26, 2009 at 6:38 pm

    I like the post. This is same problem I faced before. And solved with the same way, as you described.

  4. April 5, 2010 at 8:33 pm

    YES! Thanks SO FRIGGIN’ MUCH!

    Strange issue, really. It works locally here on my machine but once I pushed the live copy up to my dev server the load->model call wouldn’t work. I changed the first character case top lowercase and voila!

    Thanks again.

  5. April 28, 2010 at 12:49 am

    Thanks, so dumb of me, i didnt see the issue, linux and ms treat the filenames differently.

    I sure need to setup my home local web server..

    thanks again for your tip!

  6. August 9, 2010 at 1:47 pm

    thanks but , still dont work 😦

    have u got other advice ?

  7. November 23, 2010 at 8:41 pm

    sometimes “Unable to locate the model you have specified:” when the file is missing.

  8. mahrizal
    December 8, 2010 at 3:49 pm

    thank you

    it works for me

  9. Brent
    April 2, 2011 at 5:24 am

    Thank you! you saved me at least a couple of hours of banging my head against a wall!!

  10. April 9, 2011 at 5:15 pm

    Gracias!!! AhΓ­ estaba el problema

  11. rbr
    May 16, 2011 at 2:51 pm

    sii… maldito camelcase

  12. wasim kazi
    May 18, 2011 at 12:23 pm

    it’s really save my lot much time… I was trying it more than 2 hours…..

    Thanks

  13. August 1, 2011 at 4:31 am

    thanks.. its very helpfull

  14. September 19, 2011 at 2:41 pm

    problem solved thanks thanks.. !!

    • sahasra
      January 23, 2013 at 1:02 pm

      I have faced below error my application how to solve this problem i have followed user guide “news section ” when i run new it is showing below error could you please give me solution
      “Unable to locate the model you have specified: news_model”

  15. Z
    December 22, 2011 at 8:55 am

    Thank u sooo much, it works πŸ™‚

  16. gopal
    December 29, 2011 at 7:30 am

    problem solves
    i am really grateful to you……
    thank you very much

  17. Simon
    March 7, 2012 at 3:31 pm

    I have not understood how the problem was solved

  18. ku
    September 12, 2012 at 1:40 pm

    yes… its working buddy… thanks lot…

    • ku
      September 12, 2012 at 1:41 pm

      u saved my time.. πŸ™‚

  19. September 21, 2012 at 9:23 am

    can you help me, I was create website with modx I install to may computer , but when I move the file to New server, trouble : this error I found :

    “An Error Was Encountered
    Unable to locate the model you have specified: db_model”

  20. Chandra Sekhar
    January 14, 2013 at 11:39 am

    thanq so much.

  21. April 23, 2013 at 9:14 pm

    THANKSSSS BROHTTTTT LOWCASE WORKS

  22. Alan
    July 1, 2014 at 11:41 am

    Thanks πŸ™‚

  23. April 20, 2016 at 5:14 pm

    I think if you are working with Windows then you are fine, no need to rename your model name,
    BUT under Linux you need to do that 😦

  1. January 3, 2013 at 3:58 pm

Leave a reply to Mohanad Kaleia Cancel reply