33 lines
959 B
PHP
33 lines
959 B
PHP
<?php
|
|
class friendships{
|
|
// made by nolanwhy - remove if ugly
|
|
|
|
private $con;
|
|
|
|
public function __construct($con, $id) {
|
|
$this->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;
|
|
}
|
|
}
|
|
} |