function _update_7000_field_read_fields

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 modules/field/field.install
Fix fields definitions created during the d6 to d7 upgrade path.
forum_update_7003 in modules/forum/forum.install
Rename field to 'taxonomy_forums'.
image_update_7002 in modules/image/image.install
Add width and height columns to image field schema and populate.
image_update_7004 in 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 modules/field/modules/list/list.install
Rename the list field types and change 'allowed_values' format.

... See full list

File

modules/field/field.install, line 329

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.