简体   繁体   English

未定义的属性:Auth::$model [CodeIgniter]

[英]Undefined property: Auth::$model [CodeIgniter]

I know this quention might seems duplicated, but i already tried those suggestions/advice but still couldn't solve this:我知道这个问题可能看起来重复,但我已经尝试了这些建议/建议,但仍然无法解决这个问题:

environment :环境 :

$autoload['libraries'] = array('email', 'session', 'database', 'form_validation');

controller :控制器 :

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

class Auth extends CI_Controller {

public function __construct()
{
    parent::__construct();
    $this->load->library('form_validation');
    $this->load->model('Auth_model', 'Auth');
}

private function _login()
    {
        $email = $this->input->post('email');
        $password = $this->input->post('password');

        $user = $this->model->Auth->getUser();

Model :模型 :

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

class Auth_model extends CI_Model
{
    public function getUser()
    {
        $email = $this->input->post('email');
        // var_dump($email);die;
        return $this->db->get_where('t_user', ['email' => $email])->row_array();
    }
}

I Still got this error :我仍然收到此错误:

A PHP Error was encountered遇到 PHP 错误

Severity: Notice严重性:注意

Message: Undefined property: Auth::$model消息:未定义的属性:Auth::$model

Filename: controllers/Auth.php文件名:控制器/Auth.php

Line Number: 38行号:38

Change改变

   $user = $this->model->Auth->getUser();

into进入

$user = $this->Auth->getUser();

try this into the class you will use Type $ this-> library -> (" library you want ") .在您将使用的类中尝试此操作 Type $ this-> library -> (" library you want ") I hope it helps.我希望它有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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