Welcome Guest, Not a member yet? Register   Sign In
Can a helper load a model?
#5

[eluser]ejangi[/eluser]
wiredesignz is right - helpers aren't "meant" to access models, but they can through the CI singleton/controller like so:
Code:
function my_helper_function()
{
    $CI =& get_instance();
    $CI->load->model('mymodel');
    $var = $CI->mymodel->whatever();
}
The get_instance() function is in the global namespace and can be called from just about anywhere, returning the base CodeIgniter object (which all the models/libraries are properties of).


Messages In This Thread
Can a helper load a model? - by El Forum - 02-12-2008, 10:09 PM
Can a helper load a model? - by El Forum - 02-12-2008, 10:15 PM
Can a helper load a model? - by El Forum - 02-12-2008, 10:21 PM
Can a helper load a model? - by El Forum - 02-12-2008, 10:25 PM
Can a helper load a model? - by El Forum - 02-12-2008, 11:00 PM
Can a helper load a model? - by El Forum - 02-12-2008, 11:09 PM
Can a helper load a model? - by El Forum - 02-12-2008, 11:12 PM
Can a helper load a model? - by El Forum - 02-12-2008, 11:13 PM
Can a helper load a model? - by El Forum - 02-12-2008, 11:17 PM
Can a helper load a model? - by El Forum - 02-12-2008, 11:22 PM
Can a helper load a model? - by El Forum - 02-12-2008, 11:25 PM
Can a helper load a model? - by El Forum - 02-12-2008, 11:41 PM
Can a helper load a model? - by El Forum - 02-13-2008, 12:53 AM
Can a helper load a model? - by El Forum - 02-13-2008, 06:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB