Welcome Guest, Not a member yet? Register   Sign In
issue loading model in library
#2

[eluser]BrianDHall[/eluser]
Code:
class Races
{

    function Races()
    {
        $this->ci =& get_instance();
    }
    
    function get_saved_races($user_id) {
        if (! isset($this->ci->race))
        {
             $this->ci->load->model('race_model', 'race');
        }
        return $this->ci->race->get_saved_races($user_id);
    }
}

That ought to do it I believe.

The new if() just prevents multiple calls to load if it's already loaded, and since you are using $this->ci->load then the model being loaded should be located in the CI super object.

EDIT: Actually, this isn't right - it is an infinate loop. The get_saved_races function calls itself, which calls itself...

You need to fix the return value so it isn't infinately recursive, but this should answer the problems you had.


Messages In This Thread
issue loading model in library - by El Forum - 10-10-2009, 08:30 PM
issue loading model in library - by El Forum - 10-10-2009, 09:27 PM
issue loading model in library - by El Forum - 10-10-2009, 09:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB