[eluser]Unknown[/eluser]
I am having the same problem -- when I try to load a model FROM FUNCTION ie:
Code:
<?php
class MyModel extends Model {
...
public function doSomething(){
$this->load->model('ModelToBeLoaded'); // Does not work
$this->ModelToBeLoaded->someFunction();
...
}
then I get an error message like above:
Code:
Undefined property: MyModel::$ModelToBeLoaded
However, when I load the exactly the same model from CONSTRUCT, then it works:
Code:
<?php
class MyModel extends Model {
function MyModel (){
parent::Model;
$this->load->model('ModelToBeLoaded'); // Now it works
}
...
public function doSomething(){
$this->ModelToBeLoaded->someFunction();
...
}
I have spent hours to discover it...
It must be bug! At least it is very unexpected behavior and I don't want to load all function-specific models always...
EDIT:
By the way, I'm not in Controllers but in Models. My model structure is rather complicated and the problem of "multiple inheritance" may be the reason. The above-mentioned error was thrown to me, when I tried to call the model from my class trough Factory model (i.e. I am using Factory Pattern here). The Factory itself passed all unit tests, but the call to the Factory from my third model was giving a headache...