original_string: public static function delete_instances($component, $itemtype = null, $contextid = null) {
          global $DB;
  
          $sql = "SELECT ti.*, t.name, t.rawname, t.isstandard
                    FROM {tag_instance} ti
                    JOIN {tag} t
                      ON ti.tagid = t.id
                   WHERE ti.component = :component";
          $params = array('component' => $component);
          if (!is_null($contextid)) {
              $sql .= " AND ti.contextid = :contextid";
              $params['contextid'] = $contextid;
          }
          if (!is_null($itemtype)) {
              $sql .= " AND ti.itemtype = :itemtype";
              $params['itemtype'] = $itemtype;
          }
  
          if ($taginstances = $DB->get_records_sql($sql, $params)) {
              static::delete_instances_as_record($taginstances);
          }
      }
code: public static function delete_instances($component, $itemtype = null, $contextid = null) {
          global $DB;
  
          $sql = "SELECT ti.*, t.name, t.rawname, t.isstandard
                    FROM {tag_instance} ti
                    JOIN {tag} t
                      ON ti.tagid = t.id
                   WHERE ti.component = :component";
          $params = array('component' => $component);
          if (!is_null($contextid)) {
              $sql .= " AND ti.contextid = :contextid";
              $params['contextid'] = $contextid;
          }
          if (!is_null($itemtype)) {
              $sql .= " AND ti.itemtype = :itemtype";
              $params['itemtype'] = $itemtype;
          }
  
          if ($taginstances = $DB->get_records_sql($sql, $params)) {
              static::delete_instances_as_record($taginstances);
          }
      }
code_tokens: public static function delete_instances ( $ component , $ itemtype = null , $ contextid = null ) { global $ DB ; $ sql = "SELECT ti.*, t.name, t.rawname, t.isstandard
                    FROM {tag_instance} ti
                    JOIN {tag} t
                      ON ti.tagid = t.id
                   WHERE ti.component = :component" ; $ params = array ( 'component' => $ component ) ; if ( ! is_null ( $ contextid ) ) { $ sql .= " AND ti.contextid = :contextid" ; $ params [ 'contextid' ] = $ contextid ; } if ( ! is_null ( $ itemtype ) ) { $ sql .= " AND ti.itemtype = :itemtype" ; $ params [ 'itemtype' ] = $ itemtype ; } if ( $ taginstances = $ DB -> get_records_sql ( $ sql , $ params ) ) { static :: delete_instances_as_record ( $ taginstances ) ; } }
docstring: Bulk delete all tag instances for a component or tag area
  
  @param string $component
  @param string $itemtype (optional)
  @param int $contextid (optional)
docstring_tokens: Bulk delete all tag instances for a component or tag area