Can one call a method from another model in a model in CodeIgniter? Can one call a method from another model in a model in CodeIgniter? codeigniter codeigniter

Can one call a method from another model in a model in CodeIgniter?


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();  }}