I've managed to setup the RESTful API in my Codeigniter Application. Now I want to get some data from my MySQL database and pass it as JSON so I can use it in my Backbone frontend, so in my Codeigniter models folder I have created a model called category_model.php:
<?php
Class category_model extends CI_Model {
var $table_name = 'category';
function get_all_categories()
{
$this->db->select('*');
$this->db->from($this->table_name);
return $this->db->get();
}
}
?>
Then in the Codeigniter controller-folder I created a category.php file:
<?php
include(APPPATH.'libraries/REST_Controller.php');
class Category extends REST_Controller {
function __construct()
{
parent::__construct();
$this->load->model('category_model');
}
function category_get()
{
$data = $this->category_model->get_all_categories();
$this->response($data);
}
}
?>
Now, when I enter http://localhost/myproejcts/ci/index.php/category/category - I get the error {"status":false,"error":"Unknown method."} ??
what is the issue? Can someone help?