From a84e48f4064e419596edc1d1100108fab30c7714 Mon Sep 17 00:00:00 2001 From: nolanwhy <69528856+nolanwhy@users.noreply.github.com> Date: Thu, 16 Feb 2023 10:53:24 +0100 Subject: [PATCH] h --- core/classes.php | 1 + core/classes/friendships.php | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 core/classes/friendships.php diff --git a/core/classes.php b/core/classes.php index 2144c5a..e7ea306 100644 --- a/core/classes.php +++ b/core/classes.php @@ -1,6 +1,7 @@ con = $con; + } + + public function isFriends($user1, $user2) { + $sql = "SELECT * FROM friendships WHERE user1 = :user1 AND user2 = :user2 AND isAccepted = 1"; + $q = $this->con->prepare($sql); + $q->bindParam(':user1',$user1,PDO::PARAM_INT); + $q->bindParam(':user2',$user2,PDO::PARAM_INT); + $q->execute(); + $friendship = $q->fetch(); + if(!$friendship) { + $q = $this->con->prepare($sql); + $q->bindParam(':user1',$user2,PDO::PARAM_INT); + $q->bindParam(':user2',$user1,PDO::PARAM_INT); + $q->execute(); + $friendship = $q->fetch(); + if(!$friendship) { + return false; + } else { + return true; + } + } else { + return true; + } + } +} \ No newline at end of file