You are here

location_search.install in Location 5.3

Installation routines for location_search_new.

File

contrib/location_search/location_search.install
View source
<?php

/**
 * @file
 * Installation routines for location_search_new.
 */

/**
 * Implementation of hook_install().
 */
function location_search_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("\n      CREATE TABLE {location_search_work} (\n        lid int UNSIGNED NOT NULL DEFAULT '0',\n        PRIMARY KEY (lid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */");
      break;
    case 'pgsql':
      db_query("\n      CREATE TABLE {location_search_work} (\n        lid int NOT NULL DEFAULT '0' CHECK (lid >= 0),\n        PRIMARY KEY (lid)\n      )");
      break;
  }

  // Force reindexing.
  db_query('INSERT INTO {location_search_work} (SELECT lid FROM {location})');
}

/**
 * Implementation of hook_uninstall().
 */
function location_search_uninstall() {
  db_query('DROP TABLE {location_search_work}');
  variable_del('location_search_map');
  variable_del('location_search_map_address');
  variable_del('location_search_map_macro');
}

/**
 * Rewritten location_search -- Uses the fulltext engine.
 */
function location_search_update_5300() {
  $ret = array();

  // Create our worklist table.
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("\n      CREATE TABLE {location_search_work} (\n        lid int UNSIGNED NOT NULL DEFAULT '0',\n        PRIMARY KEY (lid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */");
      break;
    case 'pgsql':
      $ret[] = update_sql("\n      CREATE TABLE {location_search_work} (\n        lid int NOT NULL DEFAULT '0' CHECK (lid >= 0),\n        PRIMARY KEY (lid)\n      )");
      break;
  }

  // Force reindexing.
  $ret[] = update_sql('INSERT INTO {location_search_work} (SELECT lid FROM {location})');

  // Remove unused variables.
  variable_del('location_suppress_country');
  variable_del('location_search_distance_unit');
  return $ret;
}

Functions

Namesort descending Description
location_search_install Implementation of hook_install().
location_search_uninstall Implementation of hook_uninstall().
location_search_update_5300 Rewritten location_search -- Uses the fulltext engine.