Suppose you are using UsersController and trying to update the record of Model -User via action of edit using id parameter. Then Your code goes Here:
<?php
class UsersController extends AppController
public function edit($id = null) {
if (!$id) {
throw new NotFoundException(__('Invalid post'));
}
$user= $this->Post->findById($id);
if (!$user) {
throw new NotFoundException(__('Invalid post'));
}
if ($this->request->is(array('post', 'put'))) {
$this->User->id = $id;
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__('Your User's record has been updated.'));
return $this->redirect(array('action' => 'index'));
}
$this->Session->setFlash(__('Unable to update your User.'));
}
if (!$this->request->data) {
$this->request->data = $post;
}
}
}
?>>