Can one call a method from another model in a model in Code Igniter? I tried it out, and it seemed to work after I autoloaded all of my models.
However, does ordering of the models matter? Just because it worked for me once does not mean it works all of the time.
Yes, you can call a method from another model in a model in Code Igniter. You need the model you are calling a method on to be loaded. If you autoload all your models, it will always work. The order of autoloading does not matter.
When I want to call a method on another model, I usually load that model before using it. E.g.:
class User_model extends CI_Model
{
function test()
{
$this->load->model('Blog_model', 'blog');
$result = $this->blog->method_on_blog_model();
}
}