Welcome Guest, Not a member yet? Register   Sign In
Calling Models from other Models depends on autoload order.
#1

[eluser]Daniel Samuels[/eluser]
Hello,

If you have models A, B and C with A being the main model and B and C being smaller sub-models, you cannot call functions in B and C from A if the order of inclusion in autoload.php is

Code:
$autoload['model'] = array('a', 'b', 'c');

You have to do

Code:
$CI =& get_instance();
$CI->a->function();
$CI->b->function();

However, if you change the order to be

Code:
$autoload['model'] = array('b', 'c', 'a');

You can call the functions within B and C from A as expected, using
Code:
$this->a->function();
$this->b->function();
#2

[eluser]wiredesignz[/eluser]
Don't do it.

You can extend one Model from another and incorporate everything so simply.
#3

[eluser]Daniel Samuels[/eluser]
[quote author="wiredesignz" date="1290190025"]You can extend one Model from another and incorporate everything so simply.[/quote]

In my case these were completely separate Models and would not make sense to be extended.




Theme © iAndrew 2016 - Forum software by © MyBB