function office_hours_update_6000 in Office Hours 6
Same name and namespace in other branches
- 6.2 office_hours.install \office_hours_update_6000()
File
- ./
office_hours.install, line 36
Code
function office_hours_update_6000() {
drupal_load('module', 'content');
$ret = array();
$result = db_query("SELECT * FROM {" . content_instance_tablename() . "} WHERE widget_type = 'office_hours'");
while ($field_instance = db_fetch_object($result)) {
$name = $field_instance->field_name;
$old = db_query("SELECT * FROM {content_" . $name . "}");
while ($field = db_fetch_array($old)) {
list($hr, $min) = explode(":", $field->{$name} . "_starthours");
$start = $hr . $min;
list($hr, $min) = explode(":", $field->{$name} . "_endhours");
$end = $hr . $min;
$ret[] = update_sql("UPDATE {content_" . $name . "} SET " . $name . "_starthours = " . $start . "," . $name . "_endhours = " . $end . " WHERE nid = %d AND delta = %d", $field->nid, $field->data);
}
$ret[] = update_sql("ALTER TABLE {content_" . $name . "} CHANGE `" . $name . "_starthours` `" . $name . "_starthours` INT( 4 ) NULL DEFAULT NULL");
$ret[] = update_sql("ALTER TABLE {content_" . $name . "} CHANGE `" . $name . "_endhours` `" . $name . "_endhours` INT( 4 ) NULL DEFAULT NULL");
}
content_clear_type_cache();
return $ret;
}