public static function get_relation($competencyid, $relatedcompetencyid) {
        global $DB;

        // Lower id always as competencyid so we know which one is competencyid and which one relatedcompetencyid.
        $relation = new static();
        if ($competencyid > $relatedcompetencyid) {
            $relation->set('competencyid', $relatedcompetencyid);
            $relation->set('relatedcompetencyid', $competencyid);
        } else {
            $relation->set('competencyid', $competencyid);
            $relation->set('relatedcompetencyid', $relatedcompetencyid);
        }

        // We can do it because we have bidirectional relations in the DB.
        $params = array(
            'competencyid' => $relation->get('competencyid'),
            'relatedcompetencyid' => $relation->get('relatedcompetencyid')
        );
        if ($record = $DB->get_record(self::TABLE, $params)) {
            $relation->from_record($record);
        }

        return $relation;
    }
public static function get_relation($competencyid, $relatedcompetencyid) {
        global $DB;

        // Lower id always as competencyid so we know which one is competencyid and which one relatedcompetencyid.
        $relation = new static();
        if ($competencyid > $relatedcompetencyid) {
            $relation->set('competencyid', $relatedcompetencyid);
            $relation->set('relatedcompetencyid', $competencyid);
        } else {
            $relation->set('competencyid', $competencyid);
            $relation->set('relatedcompetencyid', $relatedcompetencyid);
        }

        // We can do it because we have bidirectional relations in the DB.
        $params = array(
            'competencyid' => $relation->get('competencyid'),
            'relatedcompetencyid' => $relation->get('relatedcompetencyid')
        );
        if ($record = $DB->get_record(self::TABLE, $params)) {
            $relation->from_record($record);
        }

        return $relation;
    }
public static function get_relation ( $ competencyid , $ relatedcompetencyid ) { global $ DB ; // Lower id always as competencyid so we know which one is competencyid and which one relatedcompetencyid. $ relation = new static ( ) ; if ( $ competencyid > $ relatedcompetencyid ) { $ relation -> set ( 'competencyid' , $ relatedcompetencyid ) ; $ relation -> set ( 'relatedcompetencyid' , $ competencyid ) ; } else { $ relation -> set ( 'competencyid' , $ competencyid ) ; $ relation -> set ( 'relatedcompetencyid' , $ relatedcompetencyid ) ; } // We can do it because we have bidirectional relations in the DB. $ params = array ( 'competencyid' => $ relation -> get ( 'competencyid' ) , 'relatedcompetencyid' => $ relation -> get ( 'relatedcompetencyid' ) ) ; if ( $ record = $ DB -> get_record ( self :: TABLE , $ params ) ) { $ relation -> from_record ( $ record ) ; } return $ relation ; }
Get relation specifying both competencies.

This does not perform any validation on the data passed. If the relation exists in the database
then it is loaded in a the model, if not then it is up to the developer to save the model.

@param int $competencyid
@param int $relatedcompetencyid
@return related_competency
Get relation specifying both competencies .