0
votes

I have 2 sites on the same domain (example.com, site2.example.com) and I am trying to make them both reference the same user tables etc from the main site (example.com) in order to have single sign on through both.

I have 2 DBs set up - one for each - and have set up a user which can access both with all the required permissions. I have altered my settings.php in the second site as below (and numerous variations of):

 $databases['default']['default'] = array(
    'driver' => 'mysql',
    'database' => 'database_site2',
    'username' => 'multi_username',
    'password' => 'multi_password',
    'host' => 'localhost',
    'prefix' => array(
      'default'   => 'database_site2.',
      'users'     => 'database_main_site.',
      'sessions'  => 'database_main_site.',
      'role'      => 'database_main_site.',
      'authmap'   => 'database_main_site.',
    ),
  );

Unfortunately when then trying to access site2 after making this change, I get the following error message:

Uncaught exception thrown in shutdown function.

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in >your SQL syntax; check the manual that corresponds to your MySQL server version for the >right syntax to use near '-amalga-01.semaphore WHERE (value = >'1471293032527ac89955a330.73110726')' at line 1: DELETE FROM {semaphore} >WHERE (value = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => >1471293032527ac89955a330.73110726 ) in lock_release_all() (line 269 of >/home/sites/amalgamart.co.uk/public_html/exampletown/includes/lock.inc).

If someone is able to help me with this I would be forever grateful!

Thanks!

1

1 Answers

0
votes

The "prefix" part of Drupal's db configuration refers to a string that is prepended to the table name within a single database, whereas you are trying to use two different databases. I don't think that this is possible in Drupal. Please read this, or you can try and see if Domain Access module could be suitable to your needs.