protected function load_courses() {
        global $DB;

        $courseids = [];
        foreach ($this->events as $event) {
            if ($course = $event->get_course()) {
                $id = $course->get('id');
                $courseids[$id] = true;
            }
        }

        if (empty($courseids)) {
            $this->courses = [];
            return;
        }

        list($idsql, $params) = $DB->get_in_or_equal(array_keys($courseids));
        $sql = "SELECT * FROM {course} WHERE id {$idsql}";

        $this->courses = $DB->get_records_sql($sql, $params);
    }
protected function load_courses() {
        global $DB;

        $courseids = [];
        foreach ($this->events as $event) {
            if ($course = $event->get_course()) {
                $id = $course->get('id');
                $courseids[$id] = true;
            }
        }

        if (empty($courseids)) {
            $this->courses = [];
            return;
        }

        list($idsql, $params) = $DB->get_in_or_equal(array_keys($courseids));
        $sql = "SELECT * FROM {course} WHERE id {$idsql}";

        $this->courses = $DB->get_records_sql($sql, $params);
    }
protected function load_courses ( ) { global $ DB ; $ courseids = [ ] ; foreach ( $ this -> events as $ event ) { if ( $ course = $ event -> get_course ( ) ) { $ id = $ course -> get ( 'id' ) ; $ courseids [ $ id ] = true ; } } if ( empty ( $ courseids ) ) { $ this -> courses = [ ] ; return ; } list ( $ idsql , $ params ) = $ DB -> get_in_or_equal ( array_keys ( $ courseids ) ) ; $ sql = "SELECT * FROM {course} WHERE id {$idsql}" ; $ this -> courses = $ DB -> get_records_sql ( $ sql , $ params ) ; }
Load the list of all of the distinct courses required for the
list of provided events and save the result in memory.
Load the list of all of the distinct courses required for the list of provided events and save the result in memory .