function block_class_update_6100 in Block Class 6.2
Same name and namespace in other branches
- 6 block_class.install \block_class_update_6100()
Implements hook_update_N().
Alters the structure of the block_class schema.
File
- ./
block_class.install, line 57 - Provides the (un)install and update logic for block_class.
Code
function block_class_update_6100() {
$status = array();
// -- Update the schema.
db_drop_primary_key($status, 'block_class');
db_change_field($status, 'block_class', 'module', 'module', array(
'type' => 'varchar',
'length' => '64',
'not null' => TRUE,
'description' => t('The module to which the block belongs.'),
));
db_change_field($status, 'block_class', 'css_class', 'css_class', array(
'type' => 'text',
'size' => 'big',
'description' => t('A serialized PHP array containing the classes for the block.'),
));
// -- Restore the primary key.
db_add_primary_key($status, 'block_class', array(
'module',
'delta',
));
// -- Convert the existing arbitrary CSS classes to the new format.
$blocks = array();
$result = db_query("SELECT module, delta, css_class FROM {block_class}");
while ($row = db_fetch_array($result)) {
$blocks[] = array(
'module' => $row['module'],
'delta' => $row['delta'],
'css_class' => serialize(array(
'_' => $row['css_class'],
)),
);
}
$key = array(
'module',
'delta',
'theme',
);
foreach ($blocks as $block) {
drupal_write_record('block_class', $block, $key);
}
return $status;
}