You are here

public function SerialFields::delete in Serial Field 7

Completely delete fields.

This function deletes tables: "field_data_NAME" and "field_revision_NAME" and entries in "field_config" and "field_config_instances".

Return value

self Object instance.

File

tests/serial.fields.inc, line 57
Serial (Fields Helper).

Class

SerialFields
Class SerialFields.

Code

public function delete() {
  foreach (array_keys($this->fields) as $name) {

    // Delete tables.
    foreach (array(
      'data',
      'revision',
    ) as $table_type) {
      $table = "field_{$table_type}_{$name}";
      if (db_table_exists($table)) {
        db_drop_table($table);
      }
    }

    // Delete entries.
    foreach (array(
      'config',
      'config_instance',
    ) as $table_type) {
      db_delete("field_{$table_type}")
        ->condition('field_name', $name)
        ->execute();
    }
  }
  return $this;
}