You are here

function text_update_5 in Content Construction Kit (CCK) 5

Consolidate into a single text field type.

File

./text.install, line 168

Code

function text_update_5() {
  $ret = array();
  $result = db_query("SELECT field_name, type, global_settings FROM {node_field} WHERE type IN ('text_shorttext', 'text_longtext')");
  while ($field = db_fetch_object($result)) {
    $global_settings = array();
    if ($field->global_settings) {
      $global_settings = unserialize($field->global_settings);
    }
    if ($field->type == 'text_shorttext') {
      $global_settings['max_length'] = '255';
    }
    else {
      $global_settings['max_length'] = '';
    }
    db_query("UPDATE {node_field} SET type = 'text', global_settings = '%s' WHERE field_name = '%s'", serialize($global_settings), $field->field_name);
  }
  db_query('DELETE FROM {cache}');
  return $ret;
}