我似乎无法加载application/model/Event.php
模型类,然后从中访问方法。
相反,CI加载application/core/App_loader.php并尝试在那里查找方法。
有人能帮忙解决这个问题吗?
在:application/config/config.php
//$config['subclass_prefix'] = 'MY_';
$config['subclass_prefix'] = 'App_';
事件.php
class Event extends CI_Model {
private $db_main;
function __construct() {
parent::__construct();
$this->db_main = $this->load->database('main', TRUE);
}
function get($arr = array()) {
// ! Trying to access this method ...
}
}
我正试图从控制器加载一个名为Event的模型类(验证函数index()是否被调用):application/controller/home.php
class Home extends App_Controller {
private $event;
function __construct() {
parent::__construct();
$this->event = $this->load->model('Event');
}
function index() {
$this->method1();
}
function method1() {
$eventArr = $this->event->get(); // << Cant access method
}
Message: Call to undefined method App_Loader::get()
application/core/App_loader.php:内部
class App_Loader extends CI_Loader {
function __construct() {
parent::__construct();
}
function aa(){}
function bb(){}
function cc(){}
}
引用取自https://www.codeigniter.com/userguide3/general/models.html#loading-a型
class Event extends CI_Model {
private $db_main;
function __construct() {
parent::__construct();
$this->db_main = $this->load->database('main', TRUE);
}
function get($arr = array()) {
// ! Trying to access this method ...
}
}
class Home extends App_Controller {
function __construct() {
parent::__construct();
$this->load->model('event');
}
function index() {
$this->method1();
}
function method1() {
$eventArr = $this->event->get();
}
}