You are here

function weather_update_7103 in Weather 7

Implement hook_update_N().

Convert settings to support heat index temperatures.

File

./weather.install, line 616
Install, update and uninstall functions for the weather module.

Code

function weather_update_7103(&$sandbox) {
  $result = db_query('SELECT * FROM {weather_display}');
  foreach ($result as $row) {
    $new['type'] = $row->type;
    $new['number'] = $row->number;
    $new['units'] = $row->units;
    $old = unserialize($row->settings);
    $settings = array(
      'data' => $old['data'],
      'show_apparent_temperature' => $old['show_windchill'],
      'show_abbreviated_directions' => $old['show_abbreviated_directions'],
      'show_directions_degree' => $old['show_directions_degree'],
      'show_compact_block' => $old['show_compact_block'],
    );
    $new['settings'] = serialize($settings);
    db_delete('weather_display')
      ->condition('type', $row->type)
      ->condition('number', $row->number)
      ->execute();
    db_insert('weather_display')
      ->fields($new)
      ->execute();
  }
}