• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Model Access

Hello Everyone,

I'm auto loading some model classes and unable to access it from admin controller.

Admin controllers are not directly inside application/controllers structure. It's structure is like application/controllers/admin/<controller_name>

Where as models are on default path application/models/<model_name>

Please refer attached screenshot and suggest me a solution how can i access model inside this kind of controller folder structure?


EDIT : Right now Instead of loading model, I created object of the model & I was able to access model class methods in admin controller.
But my question remains same, If I want to use loaded models then how can I access it without creating any object?

Attached Files Thumbnail(s)

I suggest that you open ./system/core/Codeigniter.php and see how things are loaded.
What did you Try? What did you Get? What did you Expect?

Joined the CodeIgniter Community in 2009.          ( Skype: insitfx )

(06-14-2017, 03:54 AM)InsiteFX Wrote: I suggest that you open ./system/core/Codeigniter.php and see how things are loaded.

I have auto-loaded it correctly, there is no issue with auto-loading.

| -------------------------------------------------------------------
|  Auto-load Models
| -------------------------------------------------------------------
| Prototype:
| $autoload['model'] = array('first_model', 'second_model');
| You can also supply an alternative model name to be assigned
| in the controller:
| $autoload['model'] = array('first_model' => 'first');
$autoload['model'] = array('Helper_model'=>'lib','login_model'=>'login');

Please some one suggest me solution asap. Every help is appreciated.

If the page is loading without any problems you should be able to access it via

PHP Code:
// Your helper model

// Your login model

Show us the code of your Admin Controller.
Does it have it's own constructor? Are you extending from a MY_Controller?

It worked when I tied to load model files like - "../models/<model_file_name>"

public function __construct() {

$this->load->model('../models/Helper_model', 'lib');
$this->load->model('../models/Login_model', 'login');

From controller which was inside application/controllers/admin/<controller_name>

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

Users browsing this thread:
1 Guest(s)

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.