You are here

function content_field_delete in Content Construction Kit (CCK) 5

Delete an existing field.

Parameters

$properties: An array of properties to use in selecting a field. Valid keys:

  • 'field_name' - The name of the field to be deleted.

Return value

The number of fields deleted.

File

./content_crud.inc, line 251
Create/Read/Update/Delete functions for CCK-defined object types.

Code

function content_field_delete($properties) {
  $result = db_query("SELECT type_name FROM {node_field_instance} WHERE field_name = '%s'", $properties['field_name']);
  $type_names = array();
  while ($type = db_fetch_array($result)) {
    $type_names[] = $type['type_name'];
  }
  foreach ($type_names as $type_name) {
    content_field_instance_delete(array(
      'type_name' => $type_name,
      'field_name' => $properties['field_name'],
    ));
  }
  return count($type_names) ? 1 : 0;
}