title: Codeigniter RESTful API - fetch data from MySQL and pass it as JSON
body: <p>I have a basic Codeigniter setup and I want to fetch specific data from my MySQL database and pass it as JSON data so I can use it in my Backbone frontend. Right now I'm kind of in a dead end, I dont know how to manage it, so I hope i can get some help here.</p>
  
  <p>In my Codeigniter applications folder, and then in my model folder i have:</p>
  
  <pre><code>&lt;?php
    Class category_model extends CI_Model
    {
  
      var $table_name = 'category';
      var $primary_key = 'id';
  
     function get_all_categories()
     {
      $this-&gt;db-&gt;select('*');
      $this-&gt;db-&gt;from($this-&gt;table_name);
      return $this-&gt;db-&gt;get();    
     }
  
  }
  ?&gt;
  </code></pre>
  
  <p>Then in my controlelr folder, I created an API folder which contains my category controller, category.php:</p>
  
  <pre><code>&lt;?php
  
   include(APPPATH.'./libraries/REST_Controller.php');
  
   class category extends REST_Controller {
  
   function index_get() {
      $this-&gt;load-&gt;model('category_model');
      $data=$this-&gt;get('name');
      $this-&gt;response($data); 
   }
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>This gives me <code>false</code> in the Browser...</p>
  
  <p>How do I solve this?</p>