title: How to fix this 'Call to a member function row() on boolean' error?
body: <p>I want to fetch some data from mysql. I am using codeigniter model and controller for this.</p>
  
  <p>CI_model.php : </p>
  
  <pre><code>     public function getLastSale($id){
  
  
       $q = $this-&gt;db-&gt;query("SELECT * from sma_sales  desc limit 1 where customer_id = '$id' ");
  
  
      $result = $q-&gt;row();
  
  
      $res = array();
      $res['id'] = $result-&gt;id;
      $res['paid'] = $result-&gt;paid;
  
  
      return $res; 
  
  
  }
  </code></pre>
  
  <p>CI_controller.php : </p>
  
  <pre><code>    $getLastData = $this-&gt;pos_model-&gt;getLastSale($customer_id);
  
      $sid = $getLastData['id'];
  
      $prepaid = $getLastData['paid'];
  </code></pre>
  
  <p>But this error is showing :</p>
  
  <pre><code>    An uncaught Exception was encountered
      Type: Error
  
      Message: Call to a member function row() on boolean
  </code></pre>
  
  <p>I am a beginner of codeigniter. What am i doing wrong ?</p>