function icon_install_create_fields in Icon API 8
Same name and namespace in other branches
- 7 icon.install \icon_install_create_fields()
Add fields to schema if they don't exist.
1 call to icon_install_create_fields()
- icon_block_install in modules/
icon_block/ icon_block.install - Implements hook_install().
File
- ./
icon.install, line 54 - icon.install Install, uninstall, and update functions for icon.module.
Code
function icon_install_create_fields($table, $fields) {
static $schema;
// Do not force schema refresh more than once per request.
$schema = drupal_get_module_schema('icon', $table);
foreach ($fields as $field) {
if (!empty($schema['fields'][$field])) {
if (!db_field_exists($table, $field)) {
db_add_field($table, $field, $schema['fields'][$field]);
}
else {
// The field exists, make sure field definition is up to date.
db_change_field($table, $field, $field, $schema['fields'][$field]);
}
}
}
}