function nodewords_update_2 in Nodewords: D6 Meta Tags 5
Update: nodewords.module <= version v.14 to nodewords.module version >= 1.15
File
- ./
nodewords.install, line 147
Code
function nodewords_update_2() {
$items = array();
// variable: nodewords['output'] => nodewords['head']
$settings = variable_get('nodewords', array());
if (isset($settings['output']) && !isset($settings['head'])) {
$settings['head'] = $settings['output'];
unset($settings['output']);
variable_set('nodewords', $settings);
}
// table: nid, abstract, copyright, description, keywords => type, id, name, content
$result = db_query('SELECT * FROM {nodewords} LIMIT 1');
if (db_num_rows($result) == 0) {
$items = update_sql('DROP TABLE {nodewords}');
$items = _nodewords_update_create_table();
}
else {
$row = db_fetch_array($result);
if (isset($row['keywords'])) {
// assume that the table update only needs to be run if the table contains
// the 'keywords' column
$items[] = update_sql('CREATE TEMPORARY TABLE {nodewords_tmp} AS SELECT * FROM {nodewords}');
$items[] = update_sql('DROP TABLE {nodewords}');
$items[] = _nodewords_update_create_table();
foreach (array(
'abstract',
'copyright',
'description',
'keywords',
) as $name) {
if (isset($row[$name])) {
$items[] = update_sql("INSERT INTO {nodewords} (type, id, name, content) SELECT 'node', nid, '" . $name . "', " . $name . " FROM {nodewords_tmp} WHERE " . $name . " IS NOT NULL AND " . $name . " != ''");
}
}
$items[] = update_sql('DROP TABLE {nodewords_tmp}');
}
}
return $items;
}