title: PHP - Fatal error: Call to undefined method Student_Model::getData()
body: <p>I am new to the codeigniter.i create a database and run it wamp server. It shows error as</p>
  <blockquote>
  <p>Fatal error: Call to undefined method Student_Model::getData() in
  C:\wamp\www\sundayclass\application\controllers\student.php on line 8</p>
  </blockquote>
  <p>Can anyone help me understand this error?</p>
  <p>This is my controller:</p>
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
  class Student extends CI_Controller {
  
     function index()
          {
              $this-&gt;load-&gt;model('Student_model');
              $data['result'] = $this-&gt;Student_model-&gt;getData();
              $data['page_title'] = &quot;CI Hello World App!&quot;;
   
              $this-&gt;load-&gt;view('Student_view',$data);
          }
      
  }
  </code></pre>
  <p>This is my model.php:</p>
  <pre><code>&lt;?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-&gt;db-&gt;get('data');
               
              if ($query-&gt;num_rows() &gt; 0)
              {
                  //show_error('Database is empty!');
              }else{
                  return $query-&gt;result();
              }
          }
  </code></pre>
  <p>This is my view</p>
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;?=$page_title?&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;?php foreach($result as $row):?&gt;
      &lt;h3&gt;&lt;?=$row-&gt;id?&gt;&lt;/h3&gt;
      &lt;p&gt;&lt;?=$row-&gt;name?&gt;&lt;/p&gt;
      &lt;br /&gt;
      &lt;?php endforeach;?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>