function date_update_4 in Date 5.2
Same name and namespace in other branches
- 5 date.install \date_update_4()
File
- date/
date.install, line 136
Code
function date_update_4() {
$ret = array();
drupal_load('module', 'content');
content_clear_type_cache();
$fields = content_fields();
foreach ($fields as $field) {
switch ($field['type']) {
case 'date':
$columns = array(
'value' => array(
'type' => 'varchar',
'length' => 20,
'not null' => TRUE,
'default' => "'0001-01-01T00:00:00'",
),
'timezone' => array(
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => "'GMT'",
),
);
$db_info = content_database_info($field);
if ($db_info['columns']['value']['default'] != "'0001-01-01T00:00:00'") {
content_alter_db_field(array(), array(), $field, $columns);
}
$id = $field['field_name'] . '_value';
$ret[] = update_sql("UPDATE {" . $db_info['table'] . "} SET {$id} = CONCAT(SUBSTRING({$id},1,4), '-', SUBSTRING({$id},5,2), '-', SUBSTRING({$id},7)) WHERE SUBSTRING({$id}, 5, 1) <> '-'");
}
}
db_query('DELETE FROM {cache}');
return $ret;
}