Welcome Guest, Not a member yet? Register   Sign In
$this->load->model('Blog')
#18

[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...


Messages In This Thread
$this->load->model('Blog') - by El Forum - 02-04-2010, 12:21 PM
$this->load->model('Blog') - by El Forum - 02-04-2010, 12:28 PM
$this->load->model('Blog') - by El Forum - 02-04-2010, 12:43 PM
$this->load->model('Blog') - by El Forum - 02-04-2010, 12:55 PM
$this->load->model('Blog') - by El Forum - 02-04-2010, 01:19 PM
$this->load->model('Blog') - by El Forum - 02-04-2010, 01:25 PM
$this->load->model('Blog') - by El Forum - 02-04-2010, 01:31 PM
$this->load->model('Blog') - by El Forum - 02-04-2010, 01:41 PM
$this->load->model('Blog') - by El Forum - 02-04-2010, 01:49 PM
$this->load->model('Blog') - by El Forum - 02-04-2010, 02:03 PM
$this->load->model('Blog') - by El Forum - 02-04-2010, 03:18 PM
$this->load->model('Blog') - by El Forum - 02-04-2010, 03:54 PM
$this->load->model('Blog') - by El Forum - 02-04-2010, 03:56 PM
$this->load->model('Blog') - by El Forum - 02-04-2010, 04:33 PM
$this->load->model('Blog') - by El Forum - 02-04-2010, 04:50 PM
$this->load->model('Blog') - by El Forum - 02-04-2010, 05:14 PM
$this->load->model('Blog') - by El Forum - 02-05-2010, 09:23 PM
$this->load->model('Blog') - by El Forum - 02-06-2010, 07:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB