1
votes

Two or more loaded controllers with the same name login models are not working.

E.g I have two models from same name one is login_model and other is in admin -> login_model.php then I want to load both in a single controller.

How can I do that?

4
are you using autoload are loading in page ? - JYoThI
Both will have same variable name login_model which means the one you called 2nd will be active.If you want to use both you need to use one of them as other variable.Look at doc how you can give another object name for a model - Shaiful Islam

4 Answers

3
votes

You can do this like this:

$this->load->model("login_model","login_model");

$this->load->model("admin/login_model","admin_login_model");
2
votes

You need to place admin model in another folder, say in admin folder

so your code will be like below

 $this->load->model('login_model');
 $this->load->model('admin/login_model');

This will call both model in same controller

2
votes

try this

$this->load->model('admin/login_model' , 'myinterest');
The second parameter (optional) is used to call the method.

 ex:

 $this->myinterest->get_users();
1
votes

You can use this as well:

$this->load->model("admin/login_model","login_model");