• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Instantiate model from helper

#1
[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.

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

#3
[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]


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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