大家好,当试图更新我的数据库时,这个函数没有从表中获取 id,也没有更新表中的那一行。它也抛出一个错误
$this->Relationship->id = $this->request->data['id'];
这是完整的功能
public function approve($id=null){
$this->Relationship->id = $id;
if($this->request->is('get')){
$this->request->data=$this->Relationship->read();}
$this->Relationship->id = $this->request->data['id'];
if($this->Relationship->save($this->request->data)) {
$this->Session->setFlash('Your Relationship has been updated.');
$this->redirect(array('action' => 'request'));
} else {
$this->Session->setFlash('Unable to update your post.');
}
}
}
这是表格/视图
<?php
echo $this->Form->create('Relationship', array('action'=>'approve'));
echo $this->Form->input('expirydate',array('label'=>'Expiry Date: ', 'class' => 'dateclass'));
echo $this->Form->end('Submit');
?>
我试图用这个函数做的是获取一个 id,并编辑该条目中的两个字段