original_string: public function has_related() {
          global $DB;
          $sql = "SELECT DISTINCT b.id
                      FROM {badge_related} br
                      JOIN {badge} b ON (br.relatedbadgeid = b.id OR br.badgeid = b.id)
                     WHERE (br.badgeid = :badgeid OR br.relatedbadgeid = :badgeid2) AND b.id != :badgeid3";
          return $DB->record_exists_sql($sql, ['badgeid' => $this->id, 'badgeid2' => $this->id, 'badgeid3' => $this->id]);
      }
code: public function has_related() {
          global $DB;
          $sql = "SELECT DISTINCT b.id
                      FROM {badge_related} br
                      JOIN {badge} b ON (br.relatedbadgeid = b.id OR br.badgeid = b.id)
                     WHERE (br.badgeid = :badgeid OR br.relatedbadgeid = :badgeid2) AND b.id != :badgeid3";
          return $DB->record_exists_sql($sql, ['badgeid' => $this->id, 'badgeid2' => $this->id, 'badgeid3' => $this->id]);
      }
code_tokens: public function has_related ( ) { global $ DB ; $ sql = "SELECT DISTINCT b.id
                      FROM {badge_related} br
                      JOIN {badge} b ON (br.relatedbadgeid = b.id OR br.badgeid = b.id)
                     WHERE (br.badgeid = :badgeid OR br.relatedbadgeid = :badgeid2) AND b.id != :badgeid3" ; return $ DB -> record_exists_sql ( $ sql , [ 'badgeid' => $ this -> id , 'badgeid2' => $ this -> id , 'badgeid3' => $ this -> id ] ) ; }
docstring: Checks if badge has related badges.
  
  @return bool A status related badge.
docstring_tokens: Checks if badge has related badges .