top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to delete a record in CakePHP?

0 votes
430 views
How to delete a record in CakePHP?
posted Jul 23, 2014 by Karamjeet Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

You will create a link of delete in index.ctp file of view folder.After getting an id from the link ,you can fetch the id based record and delete it in delete action of your controller .
The Code goes here:

class UsersController extends AppController
{
var $name='Users'; //controller name
var $uses='User'; //Model name which relates to the table.
function delete($id)
{
if($this->User->delete($id))
{
echo $this->Session->setFlash('Record Successfuly Deleted');
}
else
{
echo $this->Session->setFalsh('Error');
}
}

}

answer Jul 24, 2014 by Mohit Sharma
...