我有一些我一直在为我的项目工作的库存系统的代码。代码中的一切工作正常,除非您尝试更新 IID 为“1”的项目(或者至少那是我假设的问题)
function useItem($uid, $iid)
{
$sql = "UPDATE player_inv SET amount = amount - 1 WHERE uid = :uid AND iid = :iid";
$que = $this->db->prepare($sql);
$que->bindParam('uid', $uid);
$que->bindParam('iid', $iid);
try{
$que->execute();
if($que)
{
echo "True";
}
else
{
echo "Wut?";
}
}catch(PDOException $e){echo $e->getMessage();}
}
function ReapWhatYouSow($iid, $uid)
{
$sql = "UPDATE users join store on users.uid = :uid and iid = :iid SET health = store.type_value + health;";
$que = $this->db->prepare($sql);
$que->bindParam('uid', $_SESSION['uid']);
$que->bindParam('iid', $iid);
try{
$que->execute();
if($que)
{
$this->useItem($iid, $uid);
}
else
{
echo "wut?";
}
}catch(PDOException $e){ echo $e->getMessage(); }
}
请忽略回声...我真的很讨厌错误报告,所以“wut”和“true”是我检查某些东西是否正常运行的方式。