请在cakephp中查看帖子时如何保存到数据库。我有一个通知系统,我很乐意将帖子标记为“阅读”。我该如何实现这一目标? 这是我的观点代码:
public function view($id = null) {
if (!$this->Notification->exists()) {
throw new NotFoundException(__('Invalid notification'));
}elseif{
$this->request->data['Notification']['is_read'] = 1;
$this->Notification->save($this->request->data);
$this->Session->setFlash(__('The notification has been deleted.'));
}
$options = array('conditions' => array('Notification.' . $this->Notification->primaryKey => $id));
$this->set('notification', $this->Notification->find('first', $options));
}
此代码的问题在于,当第二次查看帖子时,它会一直保存。我怎么可能实现这种能力。