Welcome Guest, Not a member yet? Register   Sign In
Model Access
#1

(This post was last modified: 06-14-2017, 01:22 AM by nilam.dhok. Edit Reason: Found Some Alternative Solution )

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)
   
Reply
#2

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 CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(06-14-2017, 02: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');
Reply
#4

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

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

PHP Code:
// Your helper model
$this->lib->some_method();

// Your login model
$this->login->some_method(); 

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

(This post was last modified: 06-19-2017, 04:08 AM by nilam.dhok.)

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

public function __construct() {
parent::__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>
Reply




Theme © iAndrew 2016 - Forum software by © MyBB