Code Duplication    Length = 19-26 lines in 2 locations

models/friends_model.php 2 locations

@@ 90-115 (lines=26) @@
87
        return $requests;
88
    }
89
90
    public function get_friend_request($id)
91
    {
92
        $sql = "
93
			SELECT `request_id`,
94
					`user_id`,
95
					`sender_id`,
96
					`status`,
97
					`time`
98
			FROM " . $this->friends_request_table . "
99
			WHERE `request_id` = " . (int)$id . "
100
                AND `status` = 0
101
			ORDER BY `time` DESC
102
			LIMIT 1
103
		";
104
        $result = $this->db->sql_query($sql);
105
        $row = $this->db->sql_fetchrow($result);
106
107
        if ($this->approve_friend_request($id)) {
108
            return $row;
109
        } else {
110
            return false;
111
        }
112
    }
113
114
    public function get_request_by_sender_id($sender_id)
115
    {
116
        $sql = "
117
            SELECT `request_id`,
118
					`user_id`,
@@ 114-132 (lines=19) @@
111
        }
112
    }
113
114
    public function get_request_by_sender_id($sender_id)
115
    {
116
        $sql = "
117
            SELECT `request_id`,
118
					`user_id`,
119
					`sender_id`,
120
					`status`,
121
					`time`
122
			FROM " . $this->friends_request_table . "
123
			WHERE `sender_id` = " . (int)$sender_id . "
124
                AND `status` = 0
125
			ORDER BY `time` DESC
126
			LIMIT 1 
127
        ";
128
        $result = $this->db->sql_query($sql);
129
        $row = $this->db->sql_fetchrow($result);
130
131
        return $row;
132
    }
133
134
    public function insert_friends_request(array $data)
135
    {