Welcome Guest, Not a member yet? Register   Sign In
library manipulation - using two objects
#1

[eluser]Spir[/eluser]
Hello I need to have to object of one library in a method. How can I do that?

Do I have to do that :
Code:
$this->load->library('myLib','myLib_1');
$this->myLib_1->some_method();

$this->load->library('myLib','myLib_2');
$this->myLib_2->some_method();

I think playing with $CI =& get_instance(); would result the same.
Any idea?
#2

[eluser]Phil Sturgeon[/eluser]
The method you have posted above would not work, as it would simply send a string containing 'myLib_1' as an argument to your library's constructor, then line 2 would produce an error as $this->myLib_1 does not exist.

One way that will work is the hybrid of CI and native PHP methods.

Code:
$this->load->library('myLib');
$this->myLib->some_method();

$myLib_2 = new myLib()
$myLib_2->some_method();
#3

[eluser]Spir[/eluser]
Ok thanks I tought param 2 was like for Models.
Ok many thanks for your help.




Theme © iAndrew 2016 - Forum software by © MyBB