用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1218|回复: 1
收起左侧

[模型] 3.1.7 找不到model 问题

[复制链接]
发表于 2018-9-27 11:58:49 | 显示全部楼层 |阅读模式
本帖最后由 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复制代码
 
<?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复制代码
 
 
<?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);
    }
}
 
 
 
复制代码


发表于 2018-9-27 17:21:57 | 显示全部楼层
你 load 的是 user_model,但是你的 model 不叫这个啊。。。。。

本版积分规则