遇到PHP错误严重程度:通知消息:未定义的属性: Account::$Account_model
文件名: Admin/Account.php
行号: 19
回溯:
File: C:\xampp\htdocs\AdminLTE\application\controllers\Admin\Account.php
Line: 19
Function: _error_handler
File: C:\xampp\htdocs\AdminLTE\index.php
Line: 292
Function: require_onceclass Account extends CI_Controller {
public function _construct() {
parent::__construct();
$this->load->model('Account_model');
}
public function index() {
$mdat=[
'active_controller' => 'master',
'active_function' => 'account/account_view',
];
$this->load->view('admin/global/menu', $mdat);
$data['books']=$this->Account_model->get_all_acc();
$this->load->view('account_view',$data);
}
this is my model :
class Account_model extends CI_Model
{
var $table = 'books';
public function acc_add($data) {
$this->db->insert($this->table,$data);
return $this->db->insert_id();
}
public function get_all_acc() {
$this->db->from('books');
$query = $this->db->get();
return $query->result();
}发布于 2019-08-07 11:22:36
尝试将您的函数结构更改为以下结构:
public function __construct() {
parent::__construct();
$this->load->model('Account_model');
}因为构造函数需要双下划线,而您只需键入一个下划线
https://stackoverflow.com/questions/57386488
复制相似问题