CodeIgniter Forums

Full Version: Instantiate model from helper
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]nebulom[/eluser]
Is there a way I can instantiate my model from helper? I would like to it like this:

Code:
# user_helper.php
function user_form_session($session) {
$user = new User_model();
$user->email = $session['email'];
$user->password = $session['password'];
return $user;
}

Thanks.

El Forum

[eluser]nebulom[/eluser]
Solved. Load the model from controller who is using the helper.

El Forum

[eluser]johnpeace[/eluser]
Or do it like this:

[code] $CI =& get_instance();
$CI->load->model('your_model');
$CI->your_model->user_form_session($data);
[code]