我想制作功能,点击按钮后会将某个任务的状态改为完成。
首先,我有更新档案的问题。
功能代码:
public function change_status($id=null){
if($this->request->is('get')){
throw new MethodNotAllowedException();
}
if($this->Task->change_status($id)){
$this->Task->id = $id;
$this->Task->saveField('status', 'Finished');
}
}
按钮代码
echo ('<i class="fa fa-times-circle"></i> '.$this->Form->postLink('ChangeStatus', array('action' => 'change_status', $task['Task']['ID']), array('confirm' => 'Are You want to change status of this task?')));
在数据库中,theh字段Status是一个varchar(25),默认为“待办事项”
错误是
Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'change_status' at line 1
感谢您提前提供任何帮助。
答案 0 :(得分:4)
试试这个:
public function change_status($id=null){
if($this->request->is('post')){
$this->Task->id = $id;
$this->Task->saveField('status', 'Finished');
}else{
throw new MethodNotAllowedException();
}
}