function getlocations_fields_update_7201 in Get Locations 7.2
Add field_name field.
File
- modules/
getlocations_fields/ getlocations_fields.install, line 192 - getlocations_fields.install @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function getlocations_fields_update_7201() {
if ($result = db_field_exists('getlocations_fields', 'field_name')) {
return;
}
$spec = array(
'description' => 'Field name.',
'type' => 'varchar',
'length' => 255,
'default' => '',
'not null' => TRUE,
);
db_add_field('getlocations_fields', 'field_name', $spec);
// need to collect all field names from getlocations_fields_entities and transfer them to getlocations_fields on glid
if (db_table_exists('getlocations_fields_entities')) {
$query = db_select('getlocations_fields_entities', 'e');
$query
->fields('e', array(
'glid',
'field_name',
));
$query
->condition('e.glid', 0, '>');
$rows = $query
->execute();
foreach ($rows as $row) {
db_update('getlocations_fields')
->fields(array(
'field_name' => $row->field_name,
))
->condition('glid', $row->glid)
->execute();
}
db_drop_table('getlocations_fields_entities');
}
}