フォルダ内のフォルダ構造は次のmodules
とおりです
users->controllers->Users.php
ユーザー - >モデル - > Test_model.php
ようこそ->コントローラー->Welcome.php
Test_model.php
class 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