You are here

function domain_prefix_table_exists in Domain Access 5

Same name and namespace in other branches
  1. 6.2 domain_prefix/domain_prefix.module \domain_prefix_table_exists()

Does a table exist -- we use this to bypass Drupal's default table prefixing check.

Parameters

$prefix: The table prefix used with this domain. Optional.

$table: The name of the table being acted upon.

3 calls to domain_prefix_table_exists()
domain_prefix_drop_records in domain_prefix/domain_prefix.module
Drop tables created by this module.
domain_prefix_form in domain_prefix/domain_prefix.module
The table prefixing page for a domain.
domain_prefix_form_submit in domain_prefix/domain_prefix.module
FormsAPI for domain_prefix_form.

File

domain_prefix/domain_prefix.module, line 456
Interface for selective table prefixing for use with Domain Access. For this module to work correctly, you will need to follow the INSTALL.txt instructions for editing your settings.php file.

Code

function domain_prefix_table_exists($prefix, $table) {
  global $db_type;
  $string = db_escape_table($prefix . $table);
  switch ($db_type) {
    case 'pgsql':
      $query = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' AND table_name = '{%s}'";
      break;
    default:
      $query = "SHOW TABLES LIKE '{%s}'";
      break;
  }
  return db_num_rows(db_query($query, $string));
}