CodeIgniter Forums
ulr helper - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: ulr helper (/showthread.php?tid=42905)



ulr helper - El Forum - 06-23-2011

[eluser]jons[/eluser]
hi
How to load the model in helper,
it is possible,please help me.
Thanks Regards
Babasaheb


ulr helper - El Forum - 06-23-2011

[eluser]Arministrator[/eluser]
A model in a helper? You can load a model, or a helper. Or a library, and so on.

Either load a model from your controller with $this->load->model('some_model'); - put it in the construct if you want multiple methods to be able to use it, or put it directly in a controller method.

Or you can autoload it. Add it to the load model array in your autoload file like so:

$autoload['model'] = array('some_model');


ulr helper - El Forum - 06-23-2011

[eluser]InsiteFX[/eluser]
To load a model in a helper you need to get the CI super object instance!

To see how this is done refer to the url_helper.php in system/helpers/url_helper.php

InsiteFX


ulr helper - El Forum - 06-24-2011

[eluser]Arministrator[/eluser]
What would be the practical purpose of loading a model in a helper?


ulr helper - El Forum - 06-24-2011

[eluser]InsiteFX[/eluser]
Search the forums.