protected static function delete_data_records($context, $recordstobedeleted) {
        global $DB;
        if (empty($recordstobedeleted)) {
            return;
        }

        list($sql, $params) = $DB->get_in_or_equal($recordstobedeleted, SQL_PARAMS_NAMED);

        // Delete files.
        get_file_storage()->delete_area_files_select($context->id, 'mod_data', 'data_records',
            "IN (SELECT dc.id FROM {data_content} dc WHERE dc.recordid $sql)", $params);
        // Delete from data_content.
        $DB->delete_records_select('data_content', 'recordid ' . $sql, $params);
        // Delete from data_records.
        $DB->delete_records_select('data_records', 'id ' . $sql, $params);
        // Delete tags.
        \core_tag\privacy\provider::delete_item_tags_select($context, 'mod_data', 'data_records', $sql, $params);
        // Delete comments.
        \core_comment\privacy\provider::delete_comments_for_all_users_select($context, 'mod_data', 'database_entry', $sql, $params);
        // Delete ratings.
        \core_rating\privacy\provider::delete_ratings_select($context, 'mod_data', 'entry', $sql, $params);
    }
protected static function delete_data_records($context, $recordstobedeleted) {
        global $DB;
        if (empty($recordstobedeleted)) {
            return;
        }

        list($sql, $params) = $DB->get_in_or_equal($recordstobedeleted, SQL_PARAMS_NAMED);

        // Delete files.
        get_file_storage()->delete_area_files_select($context->id, 'mod_data', 'data_records',
            "IN (SELECT dc.id FROM {data_content} dc WHERE dc.recordid $sql)", $params);
        // Delete from data_content.
        $DB->delete_records_select('data_content', 'recordid ' . $sql, $params);
        // Delete from data_records.
        $DB->delete_records_select('data_records', 'id ' . $sql, $params);
        // Delete tags.
        \core_tag\privacy\provider::delete_item_tags_select($context, 'mod_data', 'data_records', $sql, $params);
        // Delete comments.
        \core_comment\privacy\provider::delete_comments_for_all_users_select($context, 'mod_data', 'database_entry', $sql, $params);
        // Delete ratings.
        \core_rating\privacy\provider::delete_ratings_select($context, 'mod_data', 'entry', $sql, $params);
    }
protected static function delete_data_records ( $ context , $ recordstobedeleted ) { global $ DB ; if ( empty ( $ recordstobedeleted ) ) { return ; } list ( $ sql , $ params ) = $ DB -> get_in_or_equal ( $ recordstobedeleted , SQL_PARAMS_NAMED ) ; // Delete files. get_file_storage ( ) -> delete_area_files_select ( $ context -> id , 'mod_data' , 'data_records' , "IN (SELECT dc.id FROM {data_content} dc WHERE dc.recordid $sql)" , $ params ) ; // Delete from data_content. $ DB -> delete_records_select ( 'data_content' , 'recordid ' . $ sql , $ params ) ; // Delete from data_records. $ DB -> delete_records_select ( 'data_records' , 'id ' . $ sql , $ params ) ; // Delete tags. \ core_tag \ privacy \ provider :: delete_item_tags_select ( $ context , 'mod_data' , 'data_records' , $ sql , $ params ) ; // Delete comments. \ core_comment \ privacy \ provider :: delete_comments_for_all_users_select ( $ context , 'mod_data' , 'database_entry' , $ sql , $ params ) ; // Delete ratings. \ core_rating \ privacy \ provider :: delete_ratings_select ( $ context , 'mod_data' , 'entry' , $ sql , $ params ) ; }
Deletes records marked for deletion and all associated data

Should be executed after all records were marked by {@link mark_data_content_for_deletion()}

Deletes records from data_content and data_records tables, associated files, tags, comments and ratings.

@param \context $context
@param array $recordstobedeleted list of ids of the data records that need to be deleted
Deletes records marked for deletion and all associated data