| @@ 207-225 (lines=19) @@ | ||
| 204 | ||
| 205 | } |
|
| 206 | ||
| 207 | public function check_friend($data) |
|
| 208 | { |
|
| 209 | $sql = " |
|
| 210 | SELECT COUNT(*) AS `count` |
|
| 211 | FROM " . $this->user_friends_table . " |
|
| 212 | WHERE `user_id` = " . (int)$data['user_id'] . " |
|
| 213 | AND `friend_id` = " . (int)$data['friend_id'] . " |
|
| 214 | "; |
|
| 215 | $this->db->sql_query($sql); |
|
| 216 | $count = $this->db->sql_fetchfield('count'); |
|
| 217 | if ($count > 0) { |
|
| 218 | return true; |
|
| 219 | } else { |
|
| 220 | return false; |
|
| 221 | } |
|
| 222 | } |
|
| 223 | ||
| 224 | public function check_request($data) |
|
| 225 | { |
|
| 226 | $sql = " |
|
| 227 | SELECT COUNT(*) AS `count` |
|
| 228 | FROM " . $this->friends_request_table . " |
|
| @@ 224-244 (lines=21) @@ | ||
| 221 | } |
|
| 222 | } |
|
| 223 | ||
| 224 | public function check_request($data) |
|
| 225 | { |
|
| 226 | $sql = " |
|
| 227 | SELECT COUNT(*) AS `count` |
|
| 228 | FROM " . $this->friends_request_table . " |
|
| 229 | WHERE `user_id` = " . (int)$data['user_id'] . " |
|
| 230 | AND `sender_id` = " . (int)$data['sender_id'] . " |
|
| 231 | AND `status` = 0 |
|
| 232 | LIMIT 1 |
|
| 233 | "; |
|
| 234 | $this->db->sql_query($sql); |
|
| 235 | $count = $this->db->sql_fetchfield('count'); |
|
| 236 | if ($count > 0) { |
|
| 237 | return true; |
|
| 238 | } else { |
|
| 239 | return false; |
|
| 240 | } |
|
| 241 | } |
|
| 242 | ||
| 243 | public function remove_friend($user_id) |
|
| 244 | { |
|
| 245 | $sql = "DELETE FROM " . $this->user_friends_table . " WHERE `user_id` = " . (int)$user_id . ""; |
|
| 246 | $this->db->sql_query($sql); |
|
| 247 | ||