簡體   English   中英

未定義的屬性:Auth::$model [CodeIgniter]

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

我知道這個問題可能看起來重復,但我已經嘗試了這些建議/建議,但仍然無法解決這個問題:

環境 :

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

控制器 :

<?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();

模型 :

<?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();
    }
}

我仍然收到此錯誤:

遇到 PHP 錯誤

嚴重性:注意

消息:未定義的屬性:Auth::$model

文件名:控制器/Auth.php

行號:38

改變

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

進入

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

在您將使用的類中嘗試此操作 Type $ this-> library -> (" library you want ") 我希望它有幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM