top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How to delete a record in CakePHP?

0 votes
103 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
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...