$thz_id ]; $result = $this->db->query($sql,$binds)->getResultArray() ; return $result; } public function ticketConversationList($thz_id) { $notes_sql = "SELECT thz_master_notes.*, CASE WHEN LOWER(thz_master_notes.notes_by) = 'staff' THEN CONCAT(user_profiles.first_name, ' ', user_profiles.last_name) WHEN LOWER(thz_master_notes.notes_by) = 'user' THEN thz_master.name ELSE thz_master_notes.notes_by END AS name FROM thz_master_notes LEFT JOIN user_profiles ON user_profiles.id = thz_master_notes.created_by AND LOWER(thz_master_notes.notes_by) = 'staff' LEFT JOIN thz_master ON thz_master.thz_id = thz_master_notes.thz_id AND LOWER(thz_master_notes.notes_by) = 'user' WHERE thz_master_notes.thz_id = " . (int)$thz_id . " ORDER BY thz_master_notes.created_at ASC"; $result = $this->db->query($notes_sql)->getResultArray(); return $result; } }