public function bulk_delete_instances($instances) {
        global $DB;

        $instanceids = array();
        foreach ($instances as $instance) {
            $instanceids[] = $instance->id;
        }

        // This is a multi db compatible method of creating the correct sql when using the 'IN' value.
        // $insql is the sql statement, $params are the id numbers.
        list($insql, $params) = $DB->get_in_or_equal($instanceids);
        $sql = 'id ' . $insql;
        $DB->delete_records_select('tag_instance', $sql, $params);

        // Now go through and record each tag individually with the event system.
        foreach ($instances as $instance) {
            // Trigger tag removed event (i.e. The tag instance has been removed).
            \core\event\tag_removed::create_from_tag_instance($instance, $instance->name,
                    $instance->rawname, true)->trigger();
        }
    }
public function bulk_delete_instances($instances) {
        global $DB;

        $instanceids = array();
        foreach ($instances as $instance) {
            $instanceids[] = $instance->id;
        }

        // This is a multi db compatible method of creating the correct sql when using the 'IN' value.
        // $insql is the sql statement, $params are the id numbers.
        list($insql, $params) = $DB->get_in_or_equal($instanceids);
        $sql = 'id ' . $insql;
        $DB->delete_records_select('tag_instance', $sql, $params);

        // Now go through and record each tag individually with the event system.
        foreach ($instances as $instance) {
            // Trigger tag removed event (i.e. The tag instance has been removed).
            \core\event\tag_removed::create_from_tag_instance($instance, $instance->name,
                    $instance->rawname, true)->trigger();
        }
    }
public function bulk_delete_instances ( $ instances ) { global $ DB ; $ instanceids = array ( ) ; foreach ( $ instances as $ instance ) { $ instanceids [ ] = $ instance -> id ; } // This is a multi db compatible method of creating the correct sql when using the 'IN' value. // $insql is the sql statement, $params are the id numbers. list ( $ insql , $ params ) = $ DB -> get_in_or_equal ( $ instanceids ) ; $ sql = 'id ' . $ insql ; $ DB -> delete_records_select ( 'tag_instance' , $ sql , $ params ) ; // Now go through and record each tag individually with the event system. foreach ( $ instances as $ instance ) { // Trigger tag removed event (i.e. The tag instance has been removed). \ core \ event \ tag_removed :: create_from_tag_instance ( $ instance , $ instance -> name , $ instance -> rawname , true ) -> trigger ( ) ; } }
This function will delete numerous tag instances efficiently.
This removes tag instances only. It doesn't check to see if it is the last use of a tag.

@param array $instances An array of tag instance objects with the addition of the tagname and tagrawname
(used for recording a delete event).
This function will delete numerous tag instances efficiently . This removes tag instances only . It doesn t check to see if it is the last use of a tag .