You are here

public function DataTable::dropField in Data 7

Same name and namespace in other branches
  1. 6 includes/DataTable.inc \DataTable::dropField()

Delete a field.

Throws

DataException

File

includes/DataTable.inc, line 484
Contains class definition for DataTable.

Class

DataTable
Manages data access and manipulation for a single data table. Use data_create_table() or data_get_table() to instantiate an object from this class.

Code

public function dropField($field) {
  $success = db_drop_field($this->name, $field);
  if ($success) {
    $schema = $this->table_schema;
    unset($schema['fields'][$field]);
    $meta = $this->meta;
    unset($meta['fields'][$field]);
    $this
      ->update(array(
      'table_schema' => $schema,
    ), array(
      'meta' => $meta,
    ));
    drupal_get_schema($this->name, TRUE);
    return;
  }
  throw new DataException(t('Cannot drop field.'));
}