我的功能不起作用,但它显示数据已更新的成功消息。但数据库中的数据仍然相同。
public function update(){
$mysql = new Mysql();
$query = "UPDATE module SET
modulename = '$this->name',
modulecode = '$this->code',
semesterid = '$this->semester',
departmentid = '$this->department',
programid = '$this->program'
where moduleid = '$this->id';";
$mysql->execute($query);
if($mysql->result){
$mysql->successMessage("Successfully Updated Data");
}
}
if(isset($_POST['update'])){
$module = new Module($_POST);
$module->update();
}
答案 0 :(得分:0)
我认为您正在查找受查询影响的行数而不是结果。
尝试mysql_affected_rows()以查明查询是否实际更新了任何内容。
答案 1 :(得分:-2)
尝试使用:
$query = "UPDATE module SET
modulename = '".$this->name."',
modulecode = '".$this->code."',
semesterid = '".$this->semester."',
departmentid = '".$this->department."',
programid = '".$this->program."'
where moduleid = '".$this->id;