CodeIgniter Forums
how to load a library from another librarie - 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 load a library from another librarie (/showthread.php?tid=14283)



how to load a library from another librarie - El Forum - 12-26-2008

[eluser]frietkot[/eluser]
Hi,

I've made a library called MY_Upload, handeling image uploading and stuff and extending the CI_Upload class.
But now I want to use another native library in my self made library (the image_lib library).

How do I load another library in my MY_Upload library?
Is it even posible?


how to load a library from another librarie - El Forum - 12-26-2008

[eluser]davidbehler[/eluser]
You can use this for loading libraries inside another library
Code:
$CI =& get_instance();
$CI->load->library('library_name');
and then you can use the library doing this
Code:
$CI->library_name->function_name();

That should work.


how to load a library from another librarie - El Forum - 12-26-2008

[eluser]Bramme[/eluser]
When you're extending existing CI Libraries, there usually allready is a $this->CI variable you can use to load libraries. waldmeister's code would change into:
Code:
$this-CI->load->library('library_name');

$this->CI->library_name->function_name();