【发布时间】:2015-04-14 05:40:09
【问题描述】:
我正在尝试关注 cakephp '保存数据' 2x 食谱,但我很难过。我的 UserController 有一个功能 Patient。我的表是患者信息。下面是我用来保存的代码的 sn-p:
if (isset($this->request->data['patientinformation'])) {
$this->patientinformation->create();
$this->request->data['patientinformation']['UserID']=$this->Auth->user('id');
$this->request->data['patientinformation']['Name']=$this->Auth->user('Name');
}
$this->patientinformation->id['patientinformation']['id'];
if ($this->patientinformation->save($this->patientinformation->id)){
$this->Session->setFlash(__('Your information has been saved.'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('Your information could not be saved. Please, try again.'));
如果 id 存在,我希望做的是更新记录。我无法保存我的表单数据。如果我需要在此处添加更多信息,请告诉我。
谢谢。
【问题讨论】: