致命错误:在第8行的C:\ wamp \ www \ sundayclass \ application \ controllers \ student.php中调用未定义的方法Student_Model :: getData()[关闭]

i'm new to the codeigniter.i create a data base and run it wamp server.then it shows error as "Fatal error: Call to undefined method Student_Model::getData() in C:\wamp\www\sundayclass\application\controllers\student.php on line 8"

can any one plz help me to understand the error.

thank you

this is my controller

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

class Student extends CI_Controller {

   function index()
        {
            $this->load->model('Student_model');
            $data['result'] = $this->Student_model->getData();
            $data['page_title'] = "CI Hello World App!";

            $this->load->view('Student_view',$data);
        }

}

this is my model.php

<?php
class Student_Model extends CI_Model
{
    function Student_model(){
        //call the model constructor
        parent::__construct();
        }

}function getData()
        {
            //Query the data table for every record and row
            $query = $this->db->get('data');

            if ($query->num_rows() > 0)
            {
                //show_error('Database is empty!');
            }else{
                return $query->result();
            }
        }

this is my view

<html>
<head>
    <title><?=$page_title?></title>
</head>
<body>
    <?php foreach($result as $row):?>
    <h3><?=$row->id?></h3>
    <p><?=$row->name?></p>
    <br />
    <?php endforeach;?>
</body>
</html>

Looks like your getData method is outside Student_Model class.

function getData() should be under "student_model" class.