? domain_prefix.patch
Index: domain_prefix.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain_prefix/domain_prefix.install,v
retrieving revision 1.1
diff -u -p -r1.1 domain_prefix.install
--- domain_prefix.install	10 Nov 2007 01:56:52 -0000	1.1
+++ domain_prefix.install	12 Nov 2007 23:30:09 -0000
@@ -43,7 +43,7 @@ function domain_prefix_uninstall() {
   $result = db_query("SELECT domain_id, tablename FROM {domain_prefix} WHERE status > 1");
   while ($table = db_fetch_array($result)) {
     $name = db_escape_table('domain_'. $table['domain_id'] .'_'. $table['tablename']);
-    db_query("DROP TABLE $name");
+    db_query("DROP TABLE {%s}", $name);
   }
   // Now drop the storage table.
   db_query("DROP TABLE {domain_prefix}");
Index: domain_prefix.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain_prefix/domain_prefix.module,v
retrieving revision 1.1
diff -u -p -r1.1 domain_prefix.module
--- domain_prefix.module	10 Nov 2007 01:56:52 -0000	1.1
+++ domain_prefix.module	12 Nov 2007 23:30:09 -0000
@@ -91,7 +91,7 @@ function domain_prefix_get_tables($prefi
     $result = db_query("SHOW TABLES");
   }
   else {
-    $result = db_query("SHOW TABLES LIKE '$prefix%%'");  
+    $result = db_query("SHOW TABLES LIKE '{$prefix}%%'");  
   }
   $tables = array();
   $disallow = domain_prefix_disallow();
@@ -296,7 +296,7 @@ function domain_prefix_form($domain_id) 
   // Sort them by module
   uasort($table_options, '_domain_prefix_sort');  
   // All tables are prefixed as 'domain_#_'
-  $prefix = 'domain_'. $domain_id .'_';
+  $prefix = domain_prefix_string($domain_id);
   // Generate the form.
   $form = array();
   $delete_flag = 0; // Flag for the theme function delete column
@@ -351,10 +351,10 @@ function domain_prefix_table_exists($pre
   $string = db_escape_table($prefix . $table);
   switch($db_type) {
     case 'pgsql':
-      $query = "SELECT relname FROM pg_class WHERE relname = '%s'";
+      $query = "SELECT relname FROM pg_class WHERE relname = '{%s}'";
       break;
     default:
-      $query = "SHOW TABLES LIKE '%s'";
+      $query = "SHOW TABLES LIKE '{%s}'";
       break;
   }
   return db_num_rows(db_query($query, $string));
@@ -365,7 +365,7 @@ function domain_prefix_table_exists($pre
  */
 function domain_prefix_form_submit($form_id, $form_values) {
   // Throw away what we don't need.
-  $prefix = 'domain_'. $form_values['domain_id'] .'_';
+  $prefix = domain_prefix_string($form_values['domain_id']);
   $unset = array('prefix_theme', 'domain_id', 'op', 'submit', 'restore', 'form_token', 'form_id', 'execute');
   $data = $form_values;
   foreach ($unset as $key) {
@@ -387,7 +387,7 @@ function domain_prefix_form_submit($form
     $oldtable = db_escape_table($key);
     if ($value == DOMAIN_PREFIX_CREATE) {
       if (!$exists) {
-        db_query("CREATE TABLE %s LIKE %s", $newtable, $oldtable);
+        db_query("CREATE TABLE {%s} LIKE {%s}", $newtable, $oldtable);
         drupal_set_message(t('!string table created.', array('!string' => $newtable)));
         $update = TRUE;
       }
@@ -397,8 +397,8 @@ function domain_prefix_form_submit($form
     }
     else if ($value == DOMAIN_PREFIX_COPY) {
       if (!$exists) {
-        db_query("CREATE TABLE %s LIKE %s", $newtable, $oldtable);
-        db_query("INSERT INTO %s SELECT * FROM %s", $newtable, $oldtable);
+        db_query("CREATE TABLE {%s} LIKE {%s}", $newtable, $oldtable);
+        db_query("INSERT INTO {%s} SELECT * FROM {%s}", $newtable, $oldtable);
         drupal_set_message(t('!string table copied.', array('!string' => $newtable)));
         $update = TRUE;      
       }
@@ -408,7 +408,7 @@ function domain_prefix_form_submit($form
     }
     else if ($value == DOMAIN_PREFIX_DROP) {
       if ($exists > 0) {
-        db_query("DROP TABLE %s", $newtable);
+        db_query("DROP TABLE {%s}", $newtable);
         $value = DOMAIN_PREFIX_IGNORE;
         drupal_set_message(t('!string table dropped.', array('!string' => $newtable)));      
         $update = TRUE;      
@@ -469,11 +469,11 @@ function domain_prefix_module_lookup($ta
     case 'accesslog':
       $module = 'statistics';
       break;
-     case 'term_data':
-     case 'term_hierarchy':
-     case 'term_node':
-     case 'term_relation':
-     case 'term_synonym':
+    case 'term_data':
+    case 'term_hierarchy':
+    case 'term_node':
+    case 'term_relation':
+    case 'term_synonym':
       $module = 'taxonomy';
       break;
   }
@@ -504,6 +504,7 @@ function domain_prefix_disallow() {
     'domain_conf',
     'domain_prefix',
     'domain_theme',
+    'domain_user'
   );
 }
 
@@ -536,14 +537,32 @@ function domain_prefix_domainupdate($op,
  */
 function domain_prefix_drop_records($domain_id) {
   $result = db_query("SELECT tablename FROM {domain_prefix} WHERE domain_id = %d AND status > 1", $domain_id);
-  $prefix = 'domain_'. $domain_id .'_';
+  $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);
+      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);
-}
\ No newline at end of file
+}
+
+/**
+ * Check updates
+
+function domain_prefix_update() {
+  print '<pre>';
+  print_r($_SESSION);
+  print '</pre>';
+  return 'hi';
+  
+} */
+
+/**
+ * Uniform prefix string
+ */
+function domain_prefix_string($domain_id) { 
+  return 'domain_'. $domain_id .'_'; 
+}  
\ No newline at end of file
Index: settings_domain_prefix.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain_prefix/settings_domain_prefix.inc,v
retrieving revision 1.1
diff -u -p -r1.1 settings_domain_prefix.inc
--- settings_domain_prefix.inc	10 Nov 2007 01:56:52 -0000	1.1
+++ settings_domain_prefix.inc	12 Nov 2007 23:30:10 -0000
@@ -32,13 +32,16 @@ function _domain_prefix_load() {
       }
       if (!empty($tables)) {
         global $db_prefix;
+        $new_prefix = array();
         // There might be global prefixing; if so, prepend the global.
         if (is_string($db_prefix)) {
+          $new_prefix['default'] = $db_prefix;
           $prefix = $db_prefix . $prefix;
         }
         foreach($tables as $table) {
-          $db_prefix[$table] = $prefix;
+          $new_prefix[$table] = $prefix;
         }
+        $db_prefix = $new_prefix;
       }
     }
   }
