Using get_instance and autoloaded libraries - 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: Using get_instance and autoloaded libraries (/showthread.php?tid=46819) |
Using get_instance and autoloaded libraries - El Forum - 11-16-2011 [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(); 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(); 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 |