Welcome Guest, Not a member yet? Register   Sign In
CI2 to CI3: Call to a member function helper() on a non-object in ...Session.php
#10

If you're using the controller elsewhere, I would just leave it as a controller, then extract the functionality that needs to be available in other locations into a library (to be called by all of the controllers which need it).

Storing the CI instance in a property as you've done is fairly common practice in CI libraries when the instance is needed for multiple calls. However, if you're using it to access data, you may want to consider creating a model instead of a library. As far as I know, calling a model within a model is not an issue.

Apparently being able to load a controller within a controller wasn't intended to work, and certainly wasn't a documented feature, which is why it's not mentioned in the upgrade guide. Besides, even though it appeared to work, there are some interesting bugs related to loading a controller from another controller in CI2 which are difficult to track down and nearly impossible to fix (without replacing the loader and/or controller).
Reply


Messages In This Thread
RE: CI2 to CI3: Call to a member function helper() on a non-object in ...Session.php - by mwhitney - 06-02-2015, 01:02 PM



Theme © iAndrew 2016 - Forum software by © MyBB