prepare("SELECT id FROM friends WHERE :uid IN (requesterId, receiverId) AND :rid IN (requesterId, receiverId) AND NOT status = 2"); $query->bindParam(":uid", $userid, PDO::PARAM_INT); $query->bindParam(":rid", $_POST['userID'], PDO::PARAM_INT); $query->execute(); $frId = $query->fetchColumn(); if(!$query->rowCount()){ api::respond(400, false, "Friend connection doesn't exist"); } $query = $pdo->prepare("UPDATE friends SET status = 2 WHERE id = :id"); $query->bindParam(":id", $frId, PDO::PARAM_INT); if($query->execute()){ api::respond(200, true, "OK"); } else{ api::respond(500, false, "Internal Server Error"); }