0

i've been use codeigniter with hmvc pattern.my folder structure is something like below enter image description here

Now question is how can i use adminw model in common codeigniter model ?

i've common controller which is as follow

<?php

class MY_Controller extends CI_Controller {

    public function __construct(){
        parent::__construct();
        //here i am checking url if adminw than load model inside adminw folder
        $path = $this->uri->segment(1);
        if($path != ADMIN_FOLDER){
            $this->load->model('modules/SettingModel');<-- BUT THIS IS NOT WORKING
        }else{
            $this->load->model('SettingModel');
        }
        

in short how can i load model that is stored in hmvc folder

Community
  • 1
  • 1
TarangP
  • 2,711
  • 5
  • 20
  • 41

1 Answers1

1

If your model in..

modules > admin > models > mdl_admin.php

then you can use it in any module's controllers as like..

function __construct()
{
    parent::__construct();
    $this->load->model('admin/mdl_admin','controllers_relevant_module_name');
    ....
    ....
} 

admin - Its module name,

mdl_admin - model name (admin->models->mdl_admin.php),

controllers_relevant_module_name - controller relevant module

Its just for reference.. you may modify as per your code flow requirements

Rakesh Hiray
  • 721
  • 3
  • 15