function _update_7000_field_read_fields

7.x field.install _update_7000_field_read_fields(array $conditions = array(), $key = 'id')

Utility function: fetch all the field definitions from the database.

Warning: unlike the field_read_fields() API function, this function returns all fields by default, including deleted and inactive fields, unless specified otherwise in the $conditions parameter.

Parameters

$conditions: An array of conditions to limit the select query to.

$key: The name of the field property the return array is indexed by. Using anything else than 'id' might cause incomplete results if the $conditions do not filter out deleted fields.

Return value

An array of fields matching $conditions, keyed by the property specified by the $key parameter.

Related topics

7 calls to _update_7000_field_read_fields()
field_update_7001 in drupal-7.x/modules/field/field.install
Fix fields definitions created during the d6 to d7 upgrade path.
forum_update_7003 in drupal-7.x/modules/forum/forum.install
Rename field to 'taxonomy_forums'.
image_update_7002 in drupal-7.x/modules/image/image.install
Add width and height columns to image field schema and populate.
image_update_7004 in drupal-7.x/modules/image/image.install
Use a large setting (512 and 1024 characters) for the length of the image alt and title fields.
list_update_7001 in drupal-7.x/modules/field/modules/list/list.install
Rename the list field types and change 'allowed_values' format.

... See full list

File

drupal-7.x/modules/field/field.install, line 328
Install, update and uninstall functions for the field module.

Code

function _update_7000_field_read_fields(array $conditions = array(), $key = 'id') {
  $fields = array();
  $query = db_select('field_config', 'fc', array('fetch' => PDO::FETCH_ASSOC))
    ->fields('fc');
  foreach ($conditions as $column => $value) {
    $query->condition($column, $value);
  }
  foreach ($query->execute() as $record) {
    $field = unserialize($record['data']);
    $field['id'] = $record['id'];
    $field['field_name'] = $record['field_name'];
    $field['type'] = $record['type'];
    $field['module'] = $record['module'];
    $field['active'] = $record['active'];
    $field['storage']['type'] = $record['storage_type'];
    $field['storage']['module'] = $record['storage_module'];
    $field['storage']['active'] = $record['storage_active'];
    $field['locked'] = $record['locked'];
    $field['cardinality'] = $record['cardinality'];
    $field['translatable'] = $record['translatable'];
    $field['deleted'] = $record['deleted'];

    $fields[$field[$key]] = $field;
  }
  return $fields;
}