2

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?

2
  • are you using autoload are loading in page ? Commented May 20, 2016 at 11:15
  • 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 Commented May 20, 2016 at 13:25

4 Answers 4

3

try this

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

 ex:

 $this->myinterest->get_users();
Sign up to request clarification or add additional context in comments.

Comments

3

You can do this like this:

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

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

1 Comment

This is the only answer that is correct. By the way if you are going to rename things - you actually don't need the word "model" in the name.
2

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

Comments

1

You can use this as well:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.