original_string: public static function get_competency_by_planid($planid, $competencyid) {
          global $DB;
  
          $sql = "SELECT c.*
                    FROM {" . self::TABLE . "} ucp
                    JOIN {" . competency::TABLE . "} c
                      ON c.id = ucp.competencyid
                   WHERE ucp.planid = ?
                     AND ucp.competencyid = ?";
          $record = $DB->get_record_sql($sql, array($planid, $competencyid));
  
          if (!$record) {
              throw new \coding_exception('The competency does not belong to this plan: ' . $competencyid . ', ' . $planid);
          }
  
          return new competency(0, $record);
      }
code: public static function get_competency_by_planid($planid, $competencyid) {
          global $DB;
  
          $sql = "SELECT c.*
                    FROM {" . self::TABLE . "} ucp
                    JOIN {" . competency::TABLE . "} c
                      ON c.id = ucp.competencyid
                   WHERE ucp.planid = ?
                     AND ucp.competencyid = ?";
          $record = $DB->get_record_sql($sql, array($planid, $competencyid));
  
          if (!$record) {
              throw new \coding_exception('The competency does not belong to this plan: ' . $competencyid . ', ' . $planid);
          }
  
          return new competency(0, $record);
      }
code_tokens: public static function get_competency_by_planid ( $ planid , $ competencyid ) { global $ DB ; $ sql = "SELECT c.*
                    FROM {" . self :: TABLE . "} ucp
                    JOIN {" . competency :: TABLE . "} c
                      ON c.id = ucp.competencyid
                   WHERE ucp.planid = ?
                     AND ucp.competencyid = ?" ; $ record = $ DB -> get_record_sql ( $ sql , array ( $ planid , $ competencyid ) ) ; if ( ! $ record ) { throw new \ coding_exception ( 'The competency does not belong to this plan: ' . $ competencyid . ', ' . $ planid ) ; } return new competency ( 0 , $ record ) ; }
docstring: Fetch a competency by plan ID.
  
  @param  int $id The plan ID.
  @return competency
docstring_tokens: Fetch a competency by plan ID .