title: CodeIgniter result_array() on boolean error if the table is empty
body: <p>I have this function in my <code>Carros_model.php</code> that is used to bring the last insertions and display them in the dashboard:</p>
  
  <pre><code>public function select_all($limit = 3)
  {
      $this-&gt;db
          -&gt;select('marca.nome_marca,'
                 . 'combustivel.nome_combustivel,'
                 . 'cambio.descricao_cambio,'
                 . 'DATE_FORMAT(carro.data_criacao, "%d/%m/%Y") as criacao,'
                 . 'DATE_FORMAT(carro.data_modificacao, "%d/%m/%Y") as modificacao,'
                 . 'carro.*')
          -&gt;from('carro')
          -&gt;join('marca', 'marca.id = carro.id_marca')
          -&gt;join('combustivel', 'combustivel.id = carro.id_combustivel')
          -&gt;join('cambio', 'cambio.id = carro.id_cambio')
          -&gt;order_by('carro.id', 'DESC')
          -&gt;limit($limit, 0);
  
      $query = $this-&gt;db-&gt;get();
  
      foreach ($query-&gt;result_array() as $row) {
          $data[] = $row;
      }
  
      $query-&gt;free_result();
  
      return $data;
  }
  </code></pre>
  
  <p>It works fine, but I discovered that if the table is empty, the error</p>
  
  <blockquote>
    <p>Fatal error: Call to a member function result_array() on boolean</p>
  </blockquote>
  
  <p>is thrown. How do I solve this?</p>