• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot load Model on live server

#1
[eluser]Richard Testani[/eluser]
I've been developing a CI site locally on my Mac and all is well, but when I went to test it out on a live server, I get an error.
Code:
Unable to locate the model you have specified: orders

here is the code:
Code:
class Index extends Controller {
    
    protected    $mode    =    'test';
    
    public function __construct() {
        parent::Controller();
    }
    
    public function index() {
        $this->load->database();
        $this->load->library('session');
        
        //load models
        $this->load->model('orders');
        $this->load->model('products');
        
        //load libraries
        $data['products']    =    $this->products->getAllProducts('id');
        
        if($mode = 'test') {
            $data['paypal_email']    =    "[email protected]";
            $data['paypal_host']    =    "https://www.sandbox.paypal.com/";
        } else {
            $data['paypal_email']    =    "[email protected]";
            $data['paypal_host']    =    "https://www.paypal.com/";
        }
        if(isset($_REQUEST['tx'])) {
            $this->postProcess();
        }
        
        $this->load->view('index', $data);
    }
...

This is only the first pat of the class

The model is certainly there, and simply names Orders.php. Even when I capitalize 'Orders', no match.
When I comment it out, the next model trying to load fails too.

Any ideas?
Thanks
Rich

#2
[eluser]johnnyForums[/eluser]
Does it find products?

#3
[eluser]Richard Testani[/eluser]
If I remove orders or swap the load order, the model fails to be located.

#4
[eluser]jedd[/eluser]
Instead of:
[quote author="Richard Testani" date="1249420553"]
Code:
//load models
$this->load->model('orders');
$this->load->model('products');
[/quote]

.. do this:
Code:
$this->load->model('Orders');
$this->load->model('Products');

And instead of this:
Quote:
Code:
$data['products']    =    $this->products->getAllProducts('id');

... do this:
Code:
$data['products']    =    $this->Products->getAllProducts('id');

This is covered in the CI User Guide - highly recommended reading.

#5
[eluser]Richard Testani[/eluser]
Jedd - I did try the suggestions already and getting the same error.
Libraries load fine - even my own, but for some reason it wont find the models.

Code:
public function index() {
        //load models
        $this->load->model('Orders');
        $this->load->model('Products');
        
        //load libraries
        $data['products']    =    $this->Products->getAllProducts('id');

#6
[eluser]Richard Testani[/eluser]
I installed a clean version of CI on the server, added the line:
Code:
$this->load->model('Bsn');
to the standard Welcome controller.
The model contains nothing more than a construct and I am still getting a cannot locate model error.
This is getting annoying and strange.

Any ideas - much appreciated.
Thanks
Rich

#7
[eluser]jedd[/eluser]
It might be time to actually show us your model code, specifically the function and constructor lines. And confirm what you have called your bsn model filename.

Are you sure your web server has permissions to access the new files you're creating?

What are your logs telling you?

#8
[eluser]Richard Testani[/eluser]
Jedd.

I think I found the issue which you helped lead me too.
Files names were names 'Orders.php', 'Products.php'
Seems, CI likes them all lowercase, or at least in this case Linux is case sensitive.

Thanks for you help on this!
Rich

#9
[eluser]Richard Testani[/eluser]
I'm also realizing there is a difference between __construct() and Class_name()
Seems you cant pass arguments to __construct, but the class name you can.

#10
[eluser]wiredesignz[/eluser]
@Jedd, What are you thinking? Tongue

The Codeigniter user guide specifically states all files names are lowercase except for library files which are uppercase first character only.

CodeIgniter uses lowercase names for EVERYTHING internally.

Class names must be uppercase first character only.

The library subclass extension is an exception to this and can be specified by the developer. By default it is set to "MY_".

@OP, Index is a reserved word in CodeIgniter and should not be used as a class name in any case and may be causing you some problems with the constructor running twice.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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