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