You are here

countries_api.install in Country codes API 5

Same filename and directory in other branches
  1. 6 countries_api.install

File

countries_api.install
View source
<?php

/**
 * Implementation of hook_install().
 */
function countries_api_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':

      //create countries db
      db_query("CREATE TABLE {countries_api_countries} (\n        iso2 char(2) NOT NULL DEFAULT '',\n        iso3 char(3) NOT NULL,\n        name varchar(80) NOT NULL,\n        printable_name varchar(80) NOT NULL,\n        numcode smallint(6),\n        PRIMARY KEY (iso2)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
  }

  //Include country module include for initial data import
  require_once dirname(__FILE__) . '/countries_api.module';
  countries_api_csv_import_countries();
}

/**
 * Implementation of hook_uninstall().
 */
function countries_api_uninstall() {
  db_query('DROP TABLE {countries_api_countries}');
}

/**
 * Implementation of hook_update_N().
 */
function countries_api_update_5101() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':

      // Drop table if exists.
      db_query("DROP TABLE IF EXISTS {countries_api_countries}");

      // Create countries DB table.
      $ret[] = update_sql("CREATE TABLE {countries_api_countries} (\n        iso2 char(2) NOT NULL DEFAULT '',\n        iso3 char(3) NOT NULL,\n        name varchar(80) NOT NULL,\n        printable_name varchar(80) NOT NULL,\n        numcode smallint(6),\n        PRIMARY KEY (iso2)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
  }

  //Include country module include for initial data import
  require_once dirname(__FILE__) . '/countries_api.module';
  countries_api_csv_import_countries();
  return $ret;
}

Functions

Namesort descending Description
countries_api_install Implementation of hook_install().
countries_api_uninstall Implementation of hook_uninstall().
countries_api_update_5101 Implementation of hook_update_N().