Fully RESTful server implementation for CodeIgniter and makes it dynamic to create, read, update, delete for multiple tables using only one library, one configuration file and one controller.
- PHP 5.6 or greater
- CodeIgniter 3.1.11+
- Clone this project
git clone https://github.com/liimalim/codeigniter-restserver-crud-dynamic-mysql.git
- Create database
ci3_restserver_crud
- Create table
customer
CREATE TABLE `customer` (
`id` int(11) NOT NULL,
`name` varchar(100) DEFAULT NULL,
`phone` varchar(50) DEFAULT NULL,
`address` text,
`date_created` datetime DEFAULT NULL,
`date_updated` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `customer`
ADD PRIMARY KEY (`id`);
ALTER TABLE `customer`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
Note: If you add a table to your database, you must add your table name in the application/controller/Portal.php
on line 15
Here is a API Reference for use this API:
/table_name
will return the list of all customers Examplehttp://domain/customer
/table_name/id
will only return information about the customer with id = 1 Examplehttp://domain/customer/1
This method serves to send data and save it to the database.
- URL
/table_name
Examplehttp://domain/customer
- Header
Content-Type:
application/json
- Body
{
"name":"tes name 2",
"phone":"628987654300",
"address":"Jawa Barat"
}
This method serves to update the data in the database.
- URL
/table_name/id
Ecamplehttp://domain/customer/1
- Header
Content-Type:
application/json
- Body
{
"name":"tes name 2",
"phone":"628987654300",
"address":"Jawa Barat"
}
This method serves to delete existing data in the database.
- URL
/table_name/id
Ecamplehttp://domain/customer/1
You can support the creator of this project through the link below