Creating Basic Crud With Rest
Creating Basic Crud With Rest
WITH REST
What is CRUD?
CRUD-
CREATE
READ
UPDATE
DELETE
REST
REST stands for Representational State Transfer
Any application conforming to this standard is called
RESTful.
REST is very simple and based on HTTP request
methods:
GET, POST, DELETE, and PUT.
The last two methods are not so popular in
common application development, but PUT and DELETE
can be used in the same way as POST and GET.
What is cURL?
cURL is tool that allows for data between miscellaneous
protocols, for example http, https, ftp, telnet.
You can grab it at http://curl.haxx.se/
LibcURL is a library used also by PHP.
It's installed with XAMPP under Windows and should
also be available out of the box when installing PHP
under UNIX systems.
What you need to do is to make sure that cURL is
enabled in php.ini.
In Windows, there should be an entry like the following:
function view($id) {
$recipe = $this->News->findById($id);
$this->set(compact(news));
}
}
Updating News
Deleting News
Deleting news can be done very easily by using the news
ID as a parameter to the model's delete() method:
function delete($id) {
if($this->News->delete($id)) {
$message = News deleted successfully;
} else {
$message = Error while deleting item;
}
$this->set(message,$message);
$this->render(message);
}