You are here

function fuzzysearch_uninstall in Fuzzy Search 7

Same name and namespace in other branches
  1. 6 fuzzysearch.install \fuzzysearch_uninstall()

Implements hook_uninstall().

File

./fuzzysearch.install, line 22
Install and update hook implementations of the fuzzysearch module.

Code

function fuzzysearch_uninstall() {
  if (module_exists('search_api')) {
    $query = db_select('search_api_server', 's');
    $query
      ->addField('s', 'machine_name');
    $query
      ->condition('class', 'fuzzysearch_service');
    if ($servers = $query
      ->execute()
      ->fetchAssoc()) {
      foreach ($servers as $server) {

        // Delete indexes.
        db_delete('search_api_index')
          ->condition('server', $server)
          ->execute();
      }
    }
  }
  db_delete('search_api_server')
    ->condition('class', 'fuzzysearch_service')
    ->execute();
  foreach (db_find_tables(Database::getConnection()
    ->prefixTables('{fuzzysearch}') . '%') as $table) {
    if (preg_match('/fuzzysearch_.*$/', $table, $matches)) {
      db_drop_table($matches[0]);
    }
  }
}