protected function load_module_instances() {
        global $DB;

        $this->moduleinstances = [];
        $modulestoload = [];
        foreach ($this->events as $event) {
            if ($module = $event->get_course_module()) {
                $id = $module->get('instance');
                $name = $module->get('modname');

                $ids = isset($modulestoload[$name]) ? $modulestoload[$name] : [];
                $ids[$id] = true;
                $modulestoload[$name] = $ids;
            }
        }

        if (empty($modulestoload)) {
            return;
        }

        foreach ($modulestoload as $modulename => $ids) {
            list($idsql, $params) = $DB->get_in_or_equal(array_keys($ids));
            $sql = "SELECT * FROM {" . $modulename . "} WHERE id {$idsql}";
            $this->moduleinstances[$modulename] = $DB->get_records_sql($sql, $params);
        }
    }
protected function load_module_instances() {
        global $DB;

        $this->moduleinstances = [];
        $modulestoload = [];
        foreach ($this->events as $event) {
            if ($module = $event->get_course_module()) {
                $id = $module->get('instance');
                $name = $module->get('modname');

                $ids = isset($modulestoload[$name]) ? $modulestoload[$name] : [];
                $ids[$id] = true;
                $modulestoload[$name] = $ids;
            }
        }

        if (empty($modulestoload)) {
            return;
        }

        foreach ($modulestoload as $modulename => $ids) {
            list($idsql, $params) = $DB->get_in_or_equal(array_keys($ids));
            $sql = "SELECT * FROM {" . $modulename . "} WHERE id {$idsql}";
            $this->moduleinstances[$modulename] = $DB->get_records_sql($sql, $params);
        }
    }
protected function load_module_instances ( ) { global $ DB ; $ this -> moduleinstances = [ ] ; $ modulestoload = [ ] ; foreach ( $ this -> events as $ event ) { if ( $ module = $ event -> get_course_module ( ) ) { $ id = $ module -> get ( 'instance' ) ; $ name = $ module -> get ( 'modname' ) ; $ ids = isset ( $ modulestoload [ $ name ] ) ? $ modulestoload [ $ name ] : [ ] ; $ ids [ $ id ] = true ; $ modulestoload [ $ name ] = $ ids ; } } if ( empty ( $ modulestoload ) ) { return ; } foreach ( $ modulestoload as $ modulename => $ ids ) { list ( $ idsql , $ params ) = $ DB -> get_in_or_equal ( array_keys ( $ ids ) ) ; $ sql = "SELECT * FROM {" . $ modulename . "} WHERE id {$idsql}" ; $ this -> moduleinstances [ $ modulename ] = $ DB -> get_records_sql ( $ sql , $ params ) ; } }
Load the list of all of the distinct module instances required for the
list of provided events and save the result in memory.
Load the list of all of the distinct module instances required for the list of provided events and save the result in memory .