Welcome Guest, Not a member yet? Register   Sign In
Using libraries in models
#1

[eluser]tuope[/eluser]
Hello!

I have read the "Creating Libraries" page (http://ellislab.com/codeigniter/user-gui...aries.html). How do you use library classes in models? The page mentions using library classes only in controllers.

Thanks for the help!

Tuomas
#2

[eluser]Jelmer[/eluser]
Code:
$ci =& get_instance(); // it's better to remove the & in PHP5, will cause a notice on PHP 5.3 and up
$ci->load->library('lib_name');

$val = $ci->lib_name->some_function();

Alternate option for PHP5:
Code:
get_instance()->load->library('lib_name');
$val = get_instance()->lib_name->some_function();

-------------------------

Edit: never mind, this is for using libraries in libraries. When using them in models you can use them like in controllers.
#3

[eluser]tuope[/eluser]
Thank you, Jelmer!




Theme © iAndrew 2016 - Forum software by © MyBB