Welcome Guest, Not a member yet? Register   Sign In
Loading library/model in a constructor
#1

[eluser]Shay Falador[/eluser]
Well, this is not the first time I am having problems with communicating between models to other models and libraries.
The last time I saw this kind of "bug" was when I wanted to call a model from another model, it didn't work. But a little change in the loader library fixed it.

Now I am standing against a bigger problem.. Which I partly solved.
When I am loading a library (in this case form validation) in the constructor of a model I can't use it right away.
In order to use I muse run this code immediately after loading it:
Code:
$this->_assign_libraries();

I went deep to the code and found out that every model name is assigned into an array, and whenever loading a new model or library CI goes over that array and calls _assign_libraries() for each one of these models.
The problem is that because I loaded the library in the constructor, it is not yet in that array, and therefore not included in the foreach loop.

So, I needed to manually call the method, but maybe we can find another-better solution for this problem.

Thanks for reading!
Shay


Messages In This Thread
Loading library/model in a constructor - by El Forum - 02-13-2010, 07:00 AM
Loading library/model in a constructor - by El Forum - 03-02-2010, 01:00 PM
Loading library/model in a constructor - by El Forum - 01-27-2011, 07:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB