hust313 发表于 2018-9-27 11:58:49

3.1.7 找不到model 问题

本帖最后由 hust313 于 2018-9-27 11:57 编辑


异常:
A PHP Error was encounteredSeverity: Notice
Message:Undefined property: Welcome:: $trade_mode
Filename: controllers/Welcome.php
Line Number: 37
      Backtrace:
                                                                                                                        File: /home/www/Welcome.php
                        Line: 37
                        Function: _error_handler                                                                                                                                                                File: /home/www/index.php
                        Line: 315
                        Function: require_once               




model:


Trade_model.php


<?php
class Trade_model extends CI_Model {

    public function __construct(){
      $this->load->database();
    }

    public function getTrade_id($id){
      $query = $this->db->where("tid", $id)->get('trade');
      return $query->row_array();
    }

    public function insert($data){
      return $this->db->insert('trade', $data);
    }

}




Controller

Welcome.php



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

class Welcome extends CI_Controller{

    public function index()
    {
      $this->load->view('welcome');
    }
   
    public function test(){

      $now=date('Y-m-d H:i:s');
      
      $trade=array(
                ,'trade_no'=>'4324'
                ,'trade_time'=>$now
      );
      
      $this->load->model('user_model');

      $this->user_mode->insert($trade);
    }
}




Hex 发表于 2018-9-27 17:21:57

你 load 的是 user_model,但是你的 model 不叫这个啊。。。。。
页: [1]
查看完整版本: 3.1.7 找不到model 问题