![]() |
Help! I have a recursion in my CI-Object. - 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: Help! I have a recursion in my CI-Object. (/showthread.php?tid=54763) |
Help! I have a recursion in my CI-Object. - El Forum - 09-24-2012 [eluser]RedFin[/eluser] Hello Guys, I'm new to CI and need a little help here. I have the following setup: Code: class MY_Controller extends CI_Controller { Code: $this->load->library('some-self-written-library'); Now i want to retrieve the current CI-Object in one of my self-written libraries, e.g: Code: class some-self-written-library { If i now print_r $this (like shown above), there is the following "problem": Code: Company Object How can i solve this problem, or shorter: How can i access the current ci-instance in a self-written library without creating that kind of recursion. Any ideas? I also noticed that this only happens if i load librarys inside of a self-written library. How do i solve this, if i need libraries inside of libraries? ![]() Kind regards John. Help! I have a recursion in my CI-Object. - El Forum - 09-24-2012 [eluser]PhilTem[/eluser] You won't be able to avoid that recursion. That's how CI was designed. It should actually happen in anything code that you create i.e. also models and controllers. If you need libraries inside libraries - which isn't bad at all - just do it as you got your code posted in your thread. There's no way to avoid this because this is how CI is written (just have a look at the Loader-class to understand how models, controllers, or libraries are being loaded and instantiated, then you will also understand why you get that recursion ![]() Help! I have a recursion in my CI-Object. - El Forum - 09-24-2012 [eluser]RedFin[/eluser] Thanks PhilTem ![]() |