Beispiel #1
0
 $users_id1 = getUsersId($token);
 if (!empty($users_id1)) {
     $sql = "DELETE FROM `follow` WHERE users_id1 = :users_id1 AND users_id2 = :users_id2";
     $stmt = $conn->prepare($sql);
     $stmt->bindParam(':users_id2', $users_id2);
     $stmt->bindParam(':users_id1', $users_id1);
     try {
         $stmt->execute();
     } catch (PDOException $e) {
         echo $e->getMessage();
     }
     $success = "1";
     $msg = "Successfully unfollowed!";
     $result = getAllFollowRequests($users_id1);
     $result1 = getAllFollowers($users_id1);
     $result2 = getAllFollowing($users_id1);
     if (!empty($result)) {
         $data = $result;
     }
     if (!empty($result1)) {
         $followers = $result1;
     }
     if (!empty($result2)) {
         $followings = $result2;
     }
     // $sql1="SELECT U.id, U.name AS username, CONCAT(  '$path', profile_pic )AS profile_pic, U.apn_id
     //         FROM  `follow` AS F
     //         JOIN users AS U ON F.users_id1 = U.id
     //         WHERE F.id =:follow_id";
     // $sth1=$conn->prepare($sql1);
     // $sth1->bindValue(":follow_id",$follow_id);
        if (!empty($result)) {
            $success = "1";
            $msg = "Following exist";
            $data = $result;
        } else {
            $success = "1";
            $msg = "No following";
        }
    } else {
        $success = "0";
        $msg = "No such user exist!";
    }
} elseif (!empty($others_id)) {
    $others_id = checkUsersIdExist($others_id);
    if ($others_id) {
        $result = getAllFollowing($others_id);
        if (!empty($result)) {
            $success = "1";
            $msg = "Following exist";
            $data = $result;
        } else {
            $success = "1";
            $msg = "No following";
        }
    } else {
        $success = "0";
        $msg = "No such user exist!";
    }
} else {
    $success = "0";
    $msg = "Incomplete parameters!";