首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:未定义的属性: Account::$Account_model

错误:未定义的属性: Account::$Account_model
EN

Stack Overflow用户
提问于 2019-08-07 11:14:49
回答 1查看 90关注 0票数 0

遇到PHP错误严重程度:通知消息:未定义的属性: Account::$Account_model

文件名: Admin/Account.php

行号: 19

回溯:

代码语言:javascript
复制
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_once
代码语言:javascript
复制
class 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();
    }
EN

回答 1

Stack Overflow用户

发布于 2019-08-07 11:22:36

尝试将您的函数结构更改为以下结构:

代码语言:javascript
复制
public function __construct() {
    parent::__construct();
    $this->load->model('Account_model');
}

因为构造函数需要双下划线,而您只需键入一个下划线

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57386488

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档