| 93 | | function unfollow($user_id, $follow_user_name) |
| | 92 | function request($user_id, $request_user_id) |
| | 93 | { |
| | 94 | $smt = $this->pdo->prepare(' |
| | 95 | insert into requests(user_id, request_id, created_at) |
| | 96 | values(:user_id, :request_user_id, now()) |
| | 97 | '); |
| | 98 | $smt->bindValue(':user_id', $user_id, PDO::PARAM_INT); |
| | 99 | $smt->bindValue(':request_user_id', $request_user_id, PDO::PARAM_INT); |
| | 100 | $smt->execute(); |
| | 101 | } |
| | 102 | |
| | 103 | function accept($user_id, $accept_user_id) |
| | 104 | { |
| | 105 | $this->pdo->beginTransaction(); |
| | 106 | $this->deny($user_id, $accept_user_id); |
| | 107 | $this->follow($accept_user_id, $user_id); |
| | 108 | $this->pdo->commit(); |
| | 109 | } |
| | 110 | |
| | 111 | function deny($user_id, $deny_user_id) |
| | 112 | { |
| | 113 | $smt = $this->pdo->prepare( |
| | 114 | 'delete from requests where user_id = :deny_user_id and ' . |
| | 115 | 'request_id = :user_id'); |
| | 116 | $smt->bindValue(':user_id', $user_id, PDO::PARAM_INT); |
| | 117 | $smt->bindValue(':deny_user_id', $deny_user_id, PDO::PARAM_INT); |
| | 118 | $smt->execute(); |
| | 119 | } |
| | 120 | |
| | 121 | function unfollow($user_id, $follow_user_id) |
| 103 | | |
| | 131 | function isFollowing($user_id, $follow_id) |
| | 132 | { |
| | 133 | $smt = $this->pdo->prepare(' |
| | 134 | select followers.user_id |
| | 135 | from followers |
| | 136 | where user_id = :user_id and follow_id = :follow_id |
| | 137 | limit 1 |
| | 138 | '); |
| | 139 | $smt->bindValue(':user_id', $user_id, PDO::PARAM_INT); |
| | 140 | $smt->bindValue(':follow_id', $follow_id, PDO::PARAM_INT); |
| | 141 | $smt->execute(); |
| | 142 | |
| | 143 | return $smt->fetch(PDO::FETCH_ASSOC) !== false; |
| | 144 | } |
| | 145 | function isRequesting($user_id, $follow_id) |
| | 146 | { |
| | 147 | $smt = $this->pdo->prepare(' |
| | 148 | select requests.user_id |
| | 149 | from requests |
| | 150 | where user_id = :user_id and request_id = :follow_id |
| | 151 | limit 1 |
| | 152 | '); |
| | 153 | $smt->bindValue(':user_id', $user_id, PDO::PARAM_INT); |
| | 154 | $smt->bindValue(':follow_id', $follow_id, PDO::PARAM_INT); |
| | 155 | $smt->execute(); |
| | 156 | |
| | 157 | return $smt->fetch(PDO::FETCH_ASSOC) !== false; |
| | 158 | } |