请查看代码。
当我尝试:
function new_rate($item_selection,$service_selection,$rate)
{
try
{
$stmt = $this->conn->prepare("INSERT INTO rate(Item_Id,Service_Id,Rate)
VALUES(:_item, :_service, :_rate)");
$stmt->bindparam(":_item",$item_selection);
$stmt->bindparam(":_service",$service_selection);
$stmt->bindparam(":_rate",$rate);
$stmt->execute();
return $stmt;
}
catch(PDOException $ex)
{
echo $ex->getMessage();
}
}
if(new_rate(2,8,550)){
$msg = "Rate added successfully!";
$success_msg = "";
}
else
{
$msg = "sorry , Query could not execute...";
}
有效!
但是当我尝试:
function update_query($table,$id,$update,$value)
{
try{
$stmt = $this->conn->prepare("UPDATE ".$table." SET ".$update."=:_value WHERE Id=:_id");
$stmt->bindparam(":_value",$value);
$stmt->bindparam(":_id",$id);
return $stmt->execute();
}
catch(PDOException $ex)
{
echo $ex->getMessage();
return 0;
}
}
if(update_query("rate",5,"Rate",25)){
$msg = "Rate updated successfully!";
$success_msg = "";
}
else
{
$msg = "sorry , Query could not execute...";
}
它显示:“费率更新成功!”,但不更新数据库。 我要去哪里错了?
请参见上面的代码?
我要去哪里错了?
请参见上面的代码?