Welcome Guest, Not a member yet? Register   Sign In
Is it possible to UNLOAD a model?
#5

[eluser]Nameless One[/eluser]
Sorry for bumping an old topic, but I have a solution which might help people with similar problems. I had problem with loading modules in foreach loop. The cause for this is that $this->load->model() registers the model it loads into a member variable under the assigned variable name. Even if you do unset($this->variable_name), the model will become unusable but still registered as loaded into $this->variable_name.

The solution is:
Code:
foreach ($some_array as $model_name)
{
    $this->load->model($model_name,'some_variable');
    $results[$model_name] = $this->some_variable->some_function();
    unset($this->some_variable);
    unset($this->load->_ci_models[array_search('some_variable',$this->load->_ci_models)]);
}

Not very elegant, but it is the olny way unless the CI developers decide to kindly provide us with unload() method.


Messages In This Thread
Is it possible to UNLOAD a model? - by El Forum - 11-16-2007, 10:38 AM
Is it possible to UNLOAD a model? - by El Forum - 11-16-2007, 11:51 AM
Is it possible to UNLOAD a model? - by El Forum - 11-16-2007, 12:44 PM
Is it possible to UNLOAD a model? - by El Forum - 11-17-2007, 03:59 AM
Is it possible to UNLOAD a model? - by El Forum - 04-01-2009, 10:01 AM
Is it possible to UNLOAD a model? - by El Forum - 10-17-2009, 11:02 PM
Is it possible to UNLOAD a model? - by El Forum - 10-18-2009, 07:17 AM
Is it possible to UNLOAD a model? - by El Forum - 02-17-2012, 06:42 PM
Is it possible to UNLOAD a model? - by El Forum - 02-18-2012, 02:53 AM
Is it possible to UNLOAD a model? - by El Forum - 02-20-2012, 12:12 PM
Is it possible to UNLOAD a model? - by El Forum - 02-20-2012, 01:00 PM
Is it possible to UNLOAD a model? - by El Forum - 07-12-2013, 07:08 PM
Is it possible to UNLOAD a model? - by El Forum - 07-31-2013, 09:21 PM
Is it possible to UNLOAD a model? - by El Forum - 07-31-2013, 09:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB