original_string: 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();
      }
code: 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();
      }
code_tokens: 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 ( ) ; }
docstring: 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
docstring_tokens: Adds backup id database record for all files in the given file area .