Welcome Guest, Not a member yet? Register   Sign In
Extended Model not loading in Custom Library
#1

[eluser]ray023[/eluser]
I've created a library I'm using to access some common functionality throughout my app.

Here is a trimmed version of that class:
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name:  Master View Functions
*
*/

class Master_view_functions
{
    
    function get_user_list()
    {
        $this->CI =& get_instance();
        $this->CI->load->model('User');
        return;
    }
    
}

The code works fine till
Code:
$this->CI->load->model('User');
and then it breaks.

The model it's loading is from an extended model I've coded:
Code:
<?php

class MY_Model extends Model
{
    protected $is_admin = false;
                    
    function MY_Model ()  
    {
        echo 'extended model working';
        parent::__construct();
        //parent::Model(); //This doesn't work either
    }

}
/* End of MY_Model.php */
/* Location: ./system/application/libraries/MY_code.php */

I have a Controller I've extended in a similar fashion and that works fine.

Also, this issue only happens when I deploy my app to the Host server; not in my dev environment.

I've checked the configuration settings and it *looks* ok, but I was hoping there might be someone out here who could point me in a good direction for troubleshooting.
#2

[eluser]theprodigy[/eluser]
how is it breaking?
Is it not finding the User Model?
Is it a syntax error?
#3

[eluser]whobutsb[/eluser]
In your class declaration add
Code:
var $CI;

See how that works out.
#4

[eluser]ray023[/eluser]
[quote author="theprodigy" date="1286424492"]how is it breaking?
Is it not finding the User Model?
Is it a syntax error?[/quote]

valid questions.

Though I'm not sure how to answer the first one.

Once the script hits the line to load the model, it stops loading the page.

Firebug Net Panel shows a red request that says '500 Internal Server Error' but that's all I get.

If I put echo statements in the constructors of both User and My_Model, they show in my dev environment...but not on the Host Server (FYI: hosted at FatCow.com)

My dev environment is in Windows...so I thought that maybe it was a Case issue...but that doesn't appear to be it.

I put var $CI at the top of the class but that did not help.

I feel like it is something simple like that...but, man, it's hard to troubleshoot on a remote host!
#5

[eluser]InsiteFX[/eluser]
Did you enable your error logging and check your error log?

InsiteFX
#6

[eluser]ray023[/eluser]
[quote author="InsiteFX" date="1286441112"]...check your error log?[/quote]

{Sigh}...don't know why it took that question for the light to go on above my head.

Looked in the error log on my server and found this line:
Quote:PHP Fatal error: Class 'My_Model' not found in .../my_system/application/models/user_model.php

Alas, on Linux, My_Model.php is != to MY_Model.php

Renamed the fileto MY_Model.php and all is well.

Thank-you for your patient responses.




Theme © iAndrew 2016 - Forum software by © MyBB