调用未定义的方法codeigniter异常

时间:2018-10-31 07:37:24

标签: php codeigniter

如果有人帮助我解决有关此错误的代码,我将对Codeigniter和php完全陌生,我将不胜感激。错误遇到未捕获的异常 类型:错误

  

消息:调用未定义的方法Mod_main :: getSteam()

enter image description here

模型-Mod_main.php

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

class Mod_main extends CI_Model {

    public function getSteam()
    {
        $query = $this->db->get("tbl_stream");
        if($query->num_rows() > 0){
            return $query->result();
        }
    }

    public function getDistrict()
    {
        $query = $this->db->get("tbl_district");
        if($query->num_rows() > 0){
            return $query->result();
        }
    }

}

控制器-Con_main.php

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

class Con_main extends CI_Controller {  

    public function index()
    {

        $this->load->model('mod_main');
        $getSteam= $this->mod_main->getSteam(); 
        $getDistrict = $this->mod_main->getDistrict();  
        print_r($getSteam); 
        print_r($getDistrict);  
        exit();     
        $this->load->view('main',['getSteam'=>$getSteam, 'getDistrict'=>$getDistrict]);
    }
    public function getZ()
    {
        echo "hello" ;
    }
}

1 个答案:

答案 0 :(得分:0)

类区分大小写。使用:

$this->load->model('Mod_main');
$getSteam= $this->Mod_main->getSteam();