The solution to this problem is by using a technique called 'Prefixing' whereby you prefix all the table names for that Drupal installation. In other words if you have multiple website, you can share their tables within the same database by naming them as follows:
site1_drupal_table1 site1_drupal_table2 site1_drupal_table3 ... site2_drupal_table1 site2_drupal_table2 site2_drupal_table3
The prefix can be set for each Drupal site installation by editing the file 'settings.php' and setting the $db_prefix template. So for the above example you can set the prefix for site1, but adding this line in settings.php:
$db_prefix = 'site1_';
What happens is that once you run the Drupal installation wizard for site1, all the newly created tables will have the 'site1_' prefix appended to them. This will make tables from different Drupal installations to co-exist within the same database!
Note that you can use the same trick for existing sites which have already been installed. The difference is that you need to manually rename each existing table (ex. through scripts).
No comments:
Post a Comment