简体   繁体   中英

Undefined property error with Rumbelow's My_Model in CodeIgniter

I just added Rumbelow's My_Model to CodeIgniter 3.1.9 and created a new empty model like this:

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class User_model extends MY_Model {



}

And loaded the model in my Login controller:

$this->load->model('user_model');

And this error occures: A PHP Error was encountered

Severity: Notice

Message: Undefined property: Login::$db

Filename: core/Model.php

Line Number: 73

Backtrace:

File: E:\\Projects\\My Project\\application\\core\\MY_Model.php Line: 108 Function: __get

File: E:\\Projects\\My Project\\application\\controllers\\Login.php Line: 9 Function: model

File: E:\\Projects\\My Project\\index.php Line: 316 Function: require_once

I looked for Line: 108 in My_Model.php. It's like this:

$this->_database = $this->db;

What's the problem? Is something broken with CodeIgniter 3.1?

Thanks

I just forgot to load database library. I added it to autoload.php and it works now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM