Codeigniter HMVC: неопределенное свойство $db в модели [закрыто]Php

Кемеровские программисты php общаются здесь
Anonymous
Codeigniter HMVC: неопределенное свойство $db в модели [закрыто]

Сообщение Anonymous »

Вот структура папок в папке модулей
  • users->controllers->Users.php

    users->models->Test_model.php
  • welcome->controllers->Welcome.php
Test_model.php

класс Test_model расширяет 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

Подробнее здесь: https://stackoverflow.com/questions/390 ... b-in-model

Вернуться в «Php»