title: My codeigniter model is working fine in Controller but when called in view page showing error
body: <p>this is my controller </p>
  
  <pre><code>&lt;?php
  class Site extends CI_Controller{
      public function index(){    
      $this-&gt;load-&gt;view('home');
      }
  }
  ?&gt;
  </code></pre>
  
  <p>This is my model </p>
  
  <pre><code>&lt;?php
  
  class AdminModel extends CI_Model{
  
  //function to get all the questions 
  
      function getAllQA(){
          $result=$this-&gt;db-&gt;get('question');
          if($result-&gt;num_rows()&gt;0){ //this checks if the result has something if blank means query didn't get anything from the database
          return $result;
          }
          else{
          return false;
          }
      }
  }
  ?&gt;
  </code></pre>
  
  <p>and this is my view PAge</p>
  
  <pre><code>&lt;form method="get" action=""&gt;
          &lt;div id="container"&gt;    
              &lt;?php
                  $this-&gt;load-&gt;model('adminmodel');
                  if($result=$this-&gt;adminmodel-&gt;getAllQA()){
                      foreach($result-&gt;result() as $rows){
                          echo $rows-&gt;question;
                          echo $rows-&gt;option1;
                      }
                  }
                  else{
                      echo "No question found";
                  }
              ?&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>So am calling the model in view called home.php page but its showing an error <strong>Call to a member function getAllQA() on a non-object in</strong>  So but when am calling the model in controller its working fine but why is it showing error when am loading and calling the method in view page</p>