Thank you for purchasing my plugin. If you have any questions that are beyond the scope of this help file, please feel free to email. Thanks so much!
RESTp is an advanced RESTFul Web service developed using PHP that helps you to perform crud operation. It is build on top of the popular database abstraction script "PDOModel". It is developed using PHP and can support many different database (Mysql, sqlite, pgsql and MSSQL).
//Set the host name to connect for database $config["hostname"] = "localhost"; //Set the database name $config["database"] = "pdocrud"; //Set the username for database access $config["username"] = "root"; //Set the pwd for the database user $config["password"] = ""; //Set the database type to be used $config["dbtype"] = "mysql"; //Please enter purchase code. Please check how to find purchase code details here https://help.market.envato.com/hc/en-us/articles/202822600-Where-Is-My-Purchase-Code- $config["purchase_code"] = ""; //Set the character set to be used $config["characterset"] = "utf8";
** Please make sure to take complete database backup.
Please note that if you want to change the folder name of the application, make sure to change it in .htaccess file to allow the pretty urls access work.
RESTp allows to perform CRUD (Create, Read, Update, Delete) operation on all tables of database. For every tables in database, it provides endpoints to perform CRUD operation. An example of all RESTp api endpoints for a table are below
Example endpoint with table name "orders"
There are many more functionality you can perform, which we will explain later. Let's start looking all REST methods one by one.
GET http://localhost/RestpAPI/api/orders/ {"message":"Operation done successfully","error":null, "data":[{"ID":"39","order_no":"578","order_date":"2018-08-22","customer_name":"Xenos Clarke","order_amount":"630","order_status":"Completed"}, ...,}
GET http://localhost/RestpAPI/api/orders/44 {"message":"Operation done successfully","error":null, "data":[{"ID":"44","order_no":"22241","order_date":"2018-08-22","customer_name":"Cecilia Carney","order_amount":"60","order_status":"Completed"}]}Please note that table must have primary key else use the next example to specify the column to look for.
GET http://localhost/RestpAPI/api/orders/order_no/50683 {"message":"Operation done successfully","error":null, "data":[{"ID":"57","order_no":"50683","order_date":"2018-08-22","customer_name":"Hilary Conner","order_amount":"60","order_status":"Completed"}]}
GET http://localhost/RestpAPI/api/orders/?orderby=order_date GET http://localhost/RestpAPI/api/orders/?orderby[]=order_date&orderby[]=ID// as an array for multiple sorts columns GET http://localhost/RestpAPI/api/orders/?orderby[]=order_date+desc // descending order {"message":"Operation done successfully","error":null, "data":[{"ID":"39","order_no":"578","order_date":"2018-08-22","customer_name":"Xenos Clarke","order_amount":"630","order_status":"Completed"}, ...,}
GET http://localhost/RestpAPI/api/orders/?where=order_no,2222 //default operator is = GET http://localhost/RestpAPI/api/orders/?where=order_no,2222,eq //you can specify operator here GET http://localhost/RestpAPI/api/orders/?where[]=order_no,2222:76778,bt //example of between GET http://localhost/RestpAPI/api/orders/?where[]=order_no,2222,eq,and,(&where[]=order_no,76778,eq,or&where[]=order_no,2222,eq,,) //multiple where condition //generated sql SELECT * FROM `orders` WHERE `order_no`= ? and ( `order_no`= ? or `order_no`= ? ) {"message":"Operation done successfully","error":null, "data":[{"ID":"131","order_no":"2222","order_date":"2018-08-22","customer_name":"sdfsdfc","order_amount":"60","order_status":"Completed"}]}
Available operators - lk: LIKE operator - eq: = operator - neq: != operator - lt: < operator - le: <= operator - ge: >= operator - gt: > operator - bt: between operator - in: in operator - nin: Not in operator
GET http://localhost/RestpAPI/api/orders/?groupby=order_status output: {"message":"Operation done successfully","error":null, "data":[{"ID":"39","order_no":"578","order_date":"2018-08-22","customer_name":"Xenos Clarke","order_amount":"630","order_status":"Completed"}..}]
GET http://localhost/RestpAPI/api/orders/?limit=0,10; output: {"message":"Operation done successfully","error":null, "data":[{"ID":"39","order_no":"578","order_date":"2018-08-22","customer_name":"Xenos Clarke","order_amount":"630","order_status":"Completed"}..}]
GET http://localhost/RestpAPI/api/orders/?columns=ID,order_no; output: {"message":"Operation done successfully","error":null,"data":[{"ID":"39","order_no":"578"},..}
$data = array("where" => array('order_no,2222,"eq"'), "orderby" => array("order_amount asc", "order_status desc"), "groupby" => array("order_status")); $data = http_build_query($data); GET http://localhost/RestpAPI/api/orders?".$data Above example is in php language but can be achieved in other languages also. {"message":"Operation done successfully","error":null, "data":[{"ID":"131","order_no":"2222","order_date":"2018-08-22","customer_name":"sdfsdfc","order_amount":"60","order_status":"Completed"}]}
POST http://localhost/RestpAPI/api/orders/ //data to be posted "data[order_date]=2018-08-28&data[order_amount]=800&data[order_status]=Completed"; Output: It returns last insert id. {"message":"Operation done successfully","error":null,"data":"281"}
POST http://localhost/RestpAPI/api/orders/ //data to be posted '{"data":{"order_date":"2018-08-28","order_amount":900,"order_status":"Completed"}}'; Output: It returns last insert id. {"message":"Operation done successfully","error":null,"data":"281"}
POST http://localhost/RestpAPI/api/orders/ //data to be posted "data[order_date]=2018-08-28&data[order_amount]=800&data[order_status]=Completed"; Output: It returns total number of rows updated. {"message":"Operation done successfully","error":null,"data":1}
POST http://localhost/RestpAPI/api/orders/ //data to be posted '{"data":{"order_date":"2018-08-28","order_amount":900,"order_status":"Completed"}}'; Output: It returns total number of rows updated. {"message":"Operation done successfully","error":null,"data":1}
DELETE http://localhost/RestpAPI/api/orders/57 //set CURLOPT_CUSTOMREQUEST = DELETE to do a HTTP DELETE curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
//Dummy data to delete. Please note the format of data DELETE http://localhost/RestpAPI/api/orders/57 {"where":["order_no,2222,"eq"]}
function beforeInsert($data, $obj) { return $data; } $restpAPI = new RESTpAPI(); $restpAPI->addCallback("before_insert", "beforeInsert"); $restpAPI->render();