Welcome Guest, Not a member yet? Register   Sign In
Library call within a Library
#1

[eluser]yabdab[/eluser]
Hey,

I have a Library I use to parse data located at .../application.libraries/MYParseClass.php

This class has a require() call in it for another class that is needed to do a certain task in MyParseClass.

How do I set this up so MyParseClass can use this child-helper library?

TIA

UPDATE: Looks like the obvious and simple solution works. I added this to the top of my application/libraries/MYParseClass.php file...
Code:
require_once('MYChildLibraryThatHelpsThisLibrary.php');

Only question is, is this the proper way to do this sort of thing in CI?
#2

[eluser]bretticus[/eluser]
I think the question is, "is this a supporting class only, or can it stand by itself?" If it's a supporting class only, you can probably just stick the class code in the same file. CI's loader will only load the class by the same name (as the file.) Otherwise, I think calling require_once() is fine.

If you want to use the loader class, you can get an instance of CI in your parent class.

Code:
class {
public $ci;
function __contruct()
{
$this->ci =& get_instance();
$this->ci->load->library('supporting_class');
}
}




Theme © iAndrew 2016 - Forum software by © MyBB