Author Topic: Multiple databases  (Read 4188 times)

Offline newfield86

  • Newbie
  • *
  • Posts: 3
Multiple databases
« on: April 10, 2013, 07:02:41 PM »
Hi all,

I'm trying to achieve the following by a plugin (don't wanna mess around in the source), but I have no idea how. I hope someone can help me out.

I have one domain with a roundcube installation. Multiple domains can login here: mail.domain1.com, mail.domain2.com, mail.domain3.net. I want to use a different database for each domain. So when a user login, the correct database should be selected.

Any help would be appreciated.

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,888
    • SKaero - Custom Roundcube development
Re: Multiple databases
« Reply #1 on: April 10, 2013, 08:53:15 PM »
Why? Could could do a if else in the db.inc.php if you really wanted to.

Offline newfield86

  • Newbie
  • *
  • Posts: 3
Re: Multiple databases
« Reply #2 on: April 10, 2013, 09:42:32 PM »
Because sometimes a domain should be removed and I don't want to safe the database data of that domain (users, contacts etc). So it is easier to remove a database then write scripts that cleans the database (if I use one database).

How can I write an if else in db.inc.php, based on the used domain for logging in?

Code: [Select]
if( ??? == 'mail.domain1.com')
{
    $rcmail_config['db_dsnw'] = 'mysql://user:password@localhost/database1';
}
else if( ??? == 'mail.domain2.com')
{
    $rcmail_config['db_dsnw'] = 'mysql://user:password@localhost/database2';
}
else
{
    $rcmail_config['db_dsnw'] = 'mysql://user:password@localhost/database3';
}

Offline newfield86

  • Newbie
  • *
  • Posts: 3
Re: Multiple databases
« Reply #3 on: April 12, 2013, 04:26:28 PM »
Nevermind, came up with the solution of using wildcard subdomains so I can check the HTTP_HOST in the db.inc.php.  8)