![]() |
Dynamic/variable model | variable child objects - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Dynamic/variable model | variable child objects (/showthread.php?tid=32246) |
Dynamic/variable model | variable child objects - El Forum - 07-17-2010 [eluser]loosetops[/eluser] In PHP you can access object properties and methods by using variable like this Code: $this->$property; // valid and Code: $this->$method(); //valid What I need is to access a child object (specifically a model) Code: $this->name_model->method(); // valid but with the name of the model held in a variable. Code: $object_name = 'name_model'; Thanks. Edit: All the above is valid. I just needed some sleep and a little note below made me see the bug. Dynamic/variable model | variable child objects - El Forum - 07-17-2010 [eluser]WanWizard[/eluser] What is the error you're getting? This works without problems here: Code: // load the rbac library Even this works: Code: // load the rbac library Dynamic/variable model | variable child objects - El Forum - 07-17-2010 [eluser]WanWizard[/eluser] ** double post - sorry ** Dynamic/variable model | variable child objects - El Forum - 07-17-2010 [eluser]loosetops[/eluser] Thanks. Just made me realise I was doing $this->$var-> instead of $this->ci->$var-> as the call was inside a library. |