私は自分のプロジェクトで取り組んできた在庫システムのコードをいくつか持っています。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」は、何かが正しく機能しているかどうかを確認する方法です。