[eluser]ColonelChlorine[/eluser]
I have two custom libraries, User and BadgeRules, both in the /libraries/ folder and added in the $autoload['libraries'] array. At some point inside the User library I need to call a function within the BadgeRules library. So I tried this:
Code:
$CI =& get_instance();
$CI->badgerules->somefunction($param);
And the fatal error is: "Call to a member function somefunction() on a non-object". It took me a while to figure out what was going wrong (namely I did a print_r on the $CI variable and analyzed what was being loaded). Turns out the BadgeRules library is not being autoloaded when called from get_instance.
If I replace the code with this, it works.
Code:
$CI =& get_instance();
$CI->load->library('badgerules'); //even though it is already autoloaded
$CI->badgerules->somefunction($param);
Is this intended functionality or possibly a bug with how the get_instance() returns a reference to the CodeIgniter singleton? I couldn't find anything in my searches, so I'm asking the wise CI forum crowd
Cheers,
Chlorine