Welcome Guest, Not a member yet? Register   Sign In
loading Models in libraries
#1

[eluser]Random dude[/eluser]
I've started writing a library, and I need to load a Model within the library.

should I use $CI =& get_instance(); $CI->load->model("...");
within each function?

Or can you have a constructor and create the $CI instance there? Can or should libraries have constructors?
#2

[eluser]Random dude[/eluser]
I just realized since we're passing get_instance by reference, it doesn't matter either way does it?
#3

[eluser]srisa[/eluser]
[quote author="Nicholas Reed" date="1262691148"]Or can you have a constructor and create the $CI instance there? Can or should libraries have constructors?[/quote]Yes, you can have a constructor and create the ci instance there. At the basic level library is a class, so it can have a constructor. You can skip the constructor if you don't need any initializations.




Theme © iAndrew 2016 - Forum software by © MyBB