1 回答

TA貢獻(xiàn)1880條經(jīng)驗(yàn) 獲得超4個(gè)贊
你不能使用 :param 和 ? 使用 :id 而不是 ?
但是對(duì)于更新,您可以使用
'UPDATE ' . $this->table . '
set name = :name,
course = :course
WHERE id = :id ;';
public function updateStudent(){
$query = 'UPDATE ' . $this->table . '
set name = :name,
course = :course
WHERE id = :id ;';
$stmt = $this->conn->prepare($query);
$this->id = htmlspecialchars(strip_tags($this->id));
$this->name = htmlspecialchars(strip_tags($this->name));
$this->course = htmlspecialchars(strip_tags($this->course));
$stmt->bindParam(':id', $this->id);
$stmt->bindParam(':name', $this->name);
$stmt->bindParam(':course', $this->course);
if($stmt->execute()){
return true;
}
//print error
printf("Error: %s.\n", $stmt->error);
return false;
}
- 1 回答
- 0 關(guān)注
- 510 瀏覽
添加回答
舉報(bào)