function iframe_addorchange_column in Iframe 7
Helper: add or change one column
2 calls to iframe_addorchange_column()
- iframe_update_7100 in ./
iframe.install - Update 7100 : add new column "tokensupport"
- iframe_update_7101 in ./
iframe.install - Update 7101 : adjust or synchronize length of "url" field for all users
File
- ./
iframe.install, line 95 - Install, update and uninstall functions for the text module.
Code
function iframe_addorchange_column($field_suffix, $spec) {
if (empty($field_suffix) || !is_array($spec) || !isset($spec['type'])) {
die('Cannot add or change column!');
}
$fields = iframe_get_mymodule_fields();
foreach ($fields as $field) {
if (isset($field['storage']) && isset($field['storage']['type']) && 0 !== strcmp($field['storage']['type'], 'field_sql_storage')) {
$message = t('Iframe: Cannot change field name @name because of different storage_type: @type.', array(
'@name' => $field['field_name'],
'@type' => $field['storage']['type'],
));
drupal_set_message($message, 'warning');
continue;
}
$table_prefixes = array(
_field_sql_storage_tablename($field),
_field_sql_storage_revision_tablename($field),
);
foreach ($table_prefixes as $table_prefix) {
$field_name = $field['field_name'];
// eg 'field_dimensions' ;
$column = $field_name . '_' . $field_suffix;
if (db_field_exists($table_prefix, $column)) {
db_change_field($table_prefix, $column, $column, $spec);
}
else {
db_add_field($table_prefix, $column, $spec);
}
}
}
}