Model Access |
06-13-2017, 11:52 PM
(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?
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 )
(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');
If the page is loading without any problems you should be able to access it via
PHP Code: // Your helper 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() { 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> |
Welcome Guest, Not a member yet? Register Sign In |