CodeIgniter Forums
How to call a library from a library - 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: How to call a library from a library (/showthread.php?tid=19800)



How to call a library from a library - El Forum - 06-18-2009

[eluser]skunkbad[/eluser]
I've got one library in my system/application/libraries directory, and right now I can call another library, but I am forced to put the library in the system/libraries directory. I'd like to be able to have it in my application/libraries directory, and wondering what I can change to accomplish that. Here's what I have now:

Code:
$this->CI = get_instance();
$this->CI->load->library('search');



How to call a library from a library - El Forum - 06-18-2009

[eluser]Thorpe Obazee[/eluser]
[quote author="skunkbad" date="1245401652"]

Code:
$this->CI =& get_instance();
$this->CI->load->library('search');



How to call a library from a library - El Forum - 06-18-2009

[eluser]skunkbad[/eluser]
Hmm... I had something else screwed up, because now it is working with my code


How to call a library from a library - El Forum - 06-19-2009

[eluser]TheFuzzy0ne[/eluser]
Don't forget the ampersand in there, otherwise I don't think you'll actually have the CodeIgniter super Object by reference. Instead you'd probably end up with a copy.


How to call a library from a library - El Forum - 06-19-2009

[eluser]Phil Sturgeon[/eluser]
The "&" only matters if you are using PHP 4. PHP 5 does this automatically I believe.


How to call a library from a library - El Forum - 06-19-2009

[eluser]Dam1an[/eluser]
I think you're right, cause I tried (out of curiosuty) to get_instance without the & several times, but it never increased my memory usage


How to call a library from a library - El Forum - 06-19-2009

[eluser]n0xie[/eluser]
In PHP5, all objects are passed by reference.


How to call a library from a library - El Forum - 06-19-2009

[eluser]skunkbad[/eluser]
I knew of this difference, php5 and php4 with the &. I think the issue was that I was reading the error incorrectly. It's all good now.