Codeigniter HMVC: неопределенное свойство $ db в модели

Вот структура папок в modules папка

  1. users-> controllers-> Users.php

    users-> модели-> Test_model.php

  2. welcome-> controllers-> Welcome.php

Test_model.php

класс Test_model extends CI_Model {

 function __construct() {
parent::__construct();
}

public function db_example()
{
return $this->db->get('mir_users')->result();
}
public function test(){
echo 'test model call';
}

}

И в Welcome.php

class Welcome extends MX_Controller {

public function __construct()
{
parent::__construct();
$this->load->model('users/test_model');
}
public function index()
{
//this will give the output
$this->test_model->test();
//thiw will throw error
$this->test_model->db_example();
}

$this->test_model->test() возвращает вывод, но я получу ошибку в db_example функция

Message: Undefined property: Test::$db

В autoload.php

$autoload['libraries'] = array('database');

Я использую последнюю версию HMVC

Версия Codeigniter: 3.1.0

1

Решение

Вы загрузили библиотеку базы данных два раза в автозагрузке и в модели прокомментировали эту строку в модели

$this->load->database();
1

Другие решения

Наконец я нашел решение. Проблема не в моем коде. Это с версией HMVC.

Для версий codeigniter 3.x используйте эту версию https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/downloads?tab=branches

Но я использовал не ту версию.

-1