You are here

function location_update_7302 in Location 7.3

Adds the Country code to name table "location_country".

It is created from the included array country array.

File

./location.install, line 1651
Install, update and uninstall functions for the location module.

Code

function location_update_7302() {

  // Create the new table.
  drupal_load('module', 'location');
  $schema = location_schema();
  if (!db_table_exists('location_country')) {
    db_create_table('location_country', $schema['location_country']);
  }
  else {
    db_truncate('location_country')
      ->execute();
  }
  $countries = location_get_iso3166_list();
  foreach ($countries as $code => $name) {
    db_insert('location_country')
      ->fields(array(
      'code' => $code,
      'name' => $name,
    ))
      ->execute();
  }
}