From aa4306dddd5338b719c1a95198791c126b895e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=A0=E3=81=84=E3=81=A1=E3=81=BE=E3=82=8B?= <98202777+Daichimarukana@users.noreply.github.com> Date: Thu, 17 Aug 2023 19:57:19 +0900 Subject: [PATCH] Delete favorite directory --- favorite/favorite.php | 57 ------------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 favorite/favorite.php diff --git a/favorite/favorite.php b/favorite/favorite.php deleted file mode 100644 index 0882645..0000000 --- a/favorite/favorite.php +++ /dev/null @@ -1,57 +0,0 @@ -prepare("SELECT favorite FROM ueuse WHERE uniqid = :uniqid"); - $stmt->bindValue(':uniqid', $postUniqid, PDO::PARAM_STR); - $stmt->execute(); - $post = $stmt->fetch(PDO::FETCH_ASSOC); - - if ($post) { - $favoriteList = explode(',', $post['favorite']); - $index = array_search($userId, $favoriteList); - - if ($index === false) { - // ユーザーIDを追加 - $favoriteList[] = $userId; - } else { - // ユーザーIDを削除 - array_splice($favoriteList, $index, 1); - } - - // 新しいいいね情報を更新 - $newFavorite = implode(',', $favoriteList); - $updateQuery = $pdo->prepare("UPDATE ueuse SET favorite = :favorite WHERE uniqid = :uniqid"); - $updateQuery->bindValue(':favorite', $newFavorite, PDO::PARAM_STR); - $updateQuery->bindValue(':uniqid', $postUniqid, PDO::PARAM_STR); - $res = $updateQuery->execute(); - - if ($res) { - echo json_encode(['success' => true, 'newFavorite' => $newFavorite]); - exit; - } else { - echo json_encode(['success' => false, 'error' => 'いいねの更新に失敗しました。']); - exit; - } - - - } else { - echo json_encode(['success' => false, 'error' => '投稿が見つかりません。']); - exit; - } - } catch(PDOException $e) { - echo json_encode(['success' => false, 'error' => 'データベースエラー:' . $e->getMessage()]); - exit; - } -} else { - echo json_encode(['success' => false, 'error' => '必要なパラメータが提供されていません。']); - exit; -} -?>