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

Is this possible? Example?

Have you tried? Did it work?

Don't even know where to look...? Thus, no idea.

Helpers generally assist by providing specific functions to use throughout your application, They aren't meant to be used to load CI objects.

wiredesignz is right - helpers aren't "meant" to access models, but they can through the CI singleton/controller like so:
function my_helper_function()
    $CI =& get_instance();
    $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).

I hesitated to post something like that ucant, my reason is that the CI super object is still being used to load the model (as you said), so it may as well be done properly from the controller or even autoloaded.

It's just a matter of thinking the process through when building an application. (Do I really wan't to do this here?, is there a better way?)

I just tried. No luck

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: helpers/ajax_rating_helper.php

Line Number: 11

... And what is on line 11?

some function declared in the model..

PS: model was tested and it's fine..

If you post the code, I can diagnose the issue, otherwise there's not much more I can do I'm afraid.

Theme © iAndrew 2016 - Forum software by © MyBB