CodeIgniter Forums
library manipulation - using two objects - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: library manipulation - using two objects (/showthread.php?tid=14788)



library manipulation - using two objects - El Forum - 01-15-2009

[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?


library manipulation - using two objects - El Forum - 01-15-2009

[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();



library manipulation - using two objects - El Forum - 01-15-2009

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