⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

I am using RESTful service to do CRUD on database. Can I use grocerycrud to do it?



grocerycoder
  • profile picture
  • Member

Posted 02 July 2012 - 07:30 AM

Hi, I want to use groceryCRUD to make CRUD page for my project. The problem is I don't have direct access to database, instead I am given access to the API to do the same thing at the database (CRUD). So for example when I want to do create I have to pass the parameters with POST method to http://api.example.com/create and then retrieve the result in JSON form. Have anyone tried to customize groceryCRUD to do this? Where should I start customizing grocery CRUD to get it working with REST API?

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 03 July 2012 - 20:49 PM

All the queries that grocery CRUD uses are only in file application/models/grocery_crud_model.php . So if you try to change ALL the methods of grocery_CRUD_Model for example:
change this:

function db_insert($post_array)
{
$insert = $this->db->insert($this->table_name,$post_array);
if($insert)
{
return $this->db->insert_id();
}
return false;
}

to this:

function db_insert($post_array)
{
$curl_result = my_service($post_array,'insert');

return $curl_result;//true or false
}

e.t.c....

For now it is the only solution but you can have a try if you have time of course to do it.