public static function annotate_files($backupid, $contextid, $component, $filearea, $itemid,
            \core\progress\base $progress = null) {
        global $DB;
        $sql = 'SELECT id
                  FROM {files}
                 WHERE contextid = ?
                   AND component = ?';
        $params = array($contextid, $component);

        if (!is_null($filearea)) { // Add filearea to query and params if necessary
            $sql .= ' AND filearea = ?';
            $params[] = $filearea;
        }

        if (!is_null($itemid)) { // Add itemid to query and params if necessary
            $sql .= ' AND itemid = ?';
            $params[] = $itemid;
        }
        if ($progress) {
            $progress->start_progress('');
        }
        $rs = $DB->get_recordset_sql($sql, $params);
        foreach ($rs as $record) {
            if ($progress) {
                $progress->progress();
            }
            self::insert_backup_ids_record($backupid, 'file', $record->id);
        }
        if ($progress) {
            $progress->end_progress();
        }
        $rs->close();
    }
public static function annotate_files($backupid, $contextid, $component, $filearea, $itemid,
            \core\progress\base $progress = null) {
        global $DB;
        $sql = 'SELECT id
                  FROM {files}
                 WHERE contextid = ?
                   AND component = ?';
        $params = array($contextid, $component);

        if (!is_null($filearea)) { // Add filearea to query and params if necessary
            $sql .= ' AND filearea = ?';
            $params[] = $filearea;
        }

        if (!is_null($itemid)) { // Add itemid to query and params if necessary
            $sql .= ' AND itemid = ?';
            $params[] = $itemid;
        }
        if ($progress) {
            $progress->start_progress('');
        }
        $rs = $DB->get_recordset_sql($sql, $params);
        foreach ($rs as $record) {
            if ($progress) {
                $progress->progress();
            }
            self::insert_backup_ids_record($backupid, 'file', $record->id);
        }
        if ($progress) {
            $progress->end_progress();
        }
        $rs->close();
    }
public static function annotate_files ( $ backupid , $ contextid , $ component , $ filearea , $ itemid , \ core \ progress \ base $ progress = null ) { global $ DB ; $ sql = 'SELECT id
                  FROM {files}
                 WHERE contextid = ?
                   AND component = ?' ; $ params = array ( $ contextid , $ component ) ; if ( ! is_null ( $ filearea ) ) { // Add filearea to query and params if necessary $ sql .= ' AND filearea = ?' ; $ params [ ] = $ filearea ; } if ( ! is_null ( $ itemid ) ) { // Add itemid to query and params if necessary $ sql .= ' AND itemid = ?' ; $ params [ ] = $ itemid ; } if ( $ progress ) { $ progress -> start_progress ( '' ) ; } $ rs = $ DB -> get_recordset_sql ( $ sql , $ params ) ; foreach ( $ rs as $ record ) { if ( $ progress ) { $ progress -> progress ( ) ; } self :: insert_backup_ids_record ( $ backupid , 'file' , $ record -> id ) ; } if ( $ progress ) { $ progress -> end_progress ( ) ; } $ rs -> close ( ) ; }
Adds backup id database record for all files in the given file area.

@param string $backupid Backup ID
@param int $contextid Context id
@param string $component Component
@param string $filearea File area
@param int $itemid Item id
@param \core\progress\base $progress
Adds backup id database record for all files in the given file area .