function themekey_update_6202 in ThemeKey 6.2
Same name and namespace in other branches
- 6.4 themekey.install \themekey_update_6202()
- 6.3 themekey.install \themekey_update_6202()
- 7.3 themekey.install \themekey_update_6202()
- 7 themekey.install \themekey_update_6202()
- 7.2 themekey.install \themekey_update_6202()
Implements hook_update_N().
File
- ./
themekey.install, line 306 - Database schema of @author Markus Kalkbrenner | Cocomore AG
Code
function themekey_update_6202() {
$ret = array();
$field_operator = array(
'type' => 'varchar',
'length' => 2,
'not null' => TRUE,
'default' => '=',
'initial' => '=',
);
db_add_field($ret, 'themekey_properties', 'operator', $field_operator);
$field_parent = array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'initial' => 0,
);
db_add_field($ret, 'themekey_properties', 'parent', $field_parent);
if ($result = db_query("SELECT * FROM {themekey_properties} WHERE conditions <> '%s'", serialize(array()))) {
$insert_query = "INSERT INTO {themekey_properties} (property, operator, value, weight, theme, enabled, wildcards, parent) VALUES ('%s', '%s', '%s', %d, '%s', %d, '%s', %d)";
while ($row = db_fetch_array($result)) {
$conditions = unserialize($row['conditions']);
if (is_array($conditions)) {
$parent = $row['id'];
foreach ($conditions as $condition) {
$insert_result = db_query($insert_query, $condition['property'], $condition['operator'], $condition['value'], 0, $row['theme'], $row['enabled'], serialize(array()), $parent);
if ($insert_result) {
$parent = db_last_insert_id('themekey_properties', 'id');
}
$ret[] = array(
'success' => $insert_result,
'query' => $insert_query,
);
}
}
}
}
db_drop_field($ret, 'themekey_properties', 'conditions');
db_drop_index($ret, 'themekey_properties', 'enabled');
db_drop_index($ret, 'themekey_properties', 'weight');
db_add_index($ret, 'themekey_properties', 'enabled_parent_weight', array(
'enabled',
'parent',
'weight',
));
db_add_index($ret, 'themekey_properties', 'parent_weight', array(
'parent',
'weight',
));
db_drop_index($ret, 'themekey_paths', 'path');
db_drop_index($ret, 'themekey_paths', 'fit');
db_drop_index($ret, 'themekey_paths', 'weight');
db_add_index($ret, 'themekey_paths', 'path_fit_weight', array(
'path',
'fit',
'weight',
));
return $ret;
}