This request is used to get a resource from a server e.g. list of records from table or a particular record. If you perform a `GET` request (basically Read request), the server looks for the data you requested and sends it back to you. Using RESTp, you can easily get data from a particular table or a particular record from table by specifying the where conditions. You can easily pass multiple parameters of different types, like where condition, group by, order by, pagination etc. to get required resource. RESTp select function provides a simplest way to select the data into database by passing the data in form of associative array. You need to pass table name and array of data and operation name in a particular format and rest will be managed by the script. On success, it returns the primary key value of record selected.
//init curl $ch = curl_init(); //set http headers curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); // URL to be called i.e. end point to access resource. // Example 1 curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders/"); // Example 2 //curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders/39"); // Example 3 //curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders/order_no/578"); // Example 4 - both are valid format //curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders?orderby[]=order_no+desc&groupby[]=order_status&limit=0,10"); //curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders?orderby=order_no+desc&groupby=order_status&limit=0,10"); // Example 5 //curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders/?where=order_no,2222"); //curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders/?where=order_no,2222,eq"); //curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders/?where[]=order_no,2222:76778,bt"); //curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders/?where[]=order_no,2222,eq,and,(&where[]=order_no,76778,eq,or&where[]=order_no,2222,eq,,)"); // Example 6 //$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); //curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders?".$data); //return as output instead of printing it curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //execute curl request $result = curl_exec($ch); //close curl connection curl_close($ch); //print result print_r($result);