You are here

function domain_prefix_drop_records in Domain Access 6.2

Same name and namespace in other branches
  1. 5 domain_prefix/domain_prefix.module \domain_prefix_drop_records()

Drop tables created by this module.

Parameters

$domain_id: The domain_id taken from {domain}.

1 call to domain_prefix_drop_records()
domain_prefix_domainupdate in domain_prefix/domain_prefix.module
Implement hook_domainupdate().

File

domain_prefix/domain_prefix.admin.inc, line 574
Admin page functions for selective table prefixing for use with Domain Access.

Code

function domain_prefix_drop_records($domain_id) {
  $result = db_query("SELECT tablename FROM {domain_prefix} WHERE domain_id = %d AND status > %d", $domain_id, 1);
  $prefix = domain_prefix_string($domain_id);
  while ($tables = db_fetch_array($result)) {
    $table = db_escape_table($prefix . $tables['tablename']);
    $exists = domain_prefix_table_exists($prefix, $tables['tablename']);
    if ($exists > 0) {
      db_query("DROP TABLE {%s}", $table);
      drupal_set_message(t('!string table dropped.', array(
        '!string' => $table,
      )));
    }
  }
  db_query("DELETE FROM {domain_prefix} WHERE domain_id = %d", $domain_id);
}