[support] Multiple DB connections within hook_cron

Chris Johnson cxjohnson at gmail.com
Fri Jan 25 17:24:37 UTC 2008


You don't need to use $db_prefix to use multiple databases.  It has an
entirely different purpose.  It's job is prefix the table names within
a given database to prevent collision with other tables of the same
name, perhaps being used by another application, or by multiple
instances of Drupal sharing the same database.  It's mostly there to
help folks who have low-end hosting arrangements and have one or
limited databases.

On Jan 25, 2008 1:48 PM, Tane Piper <digitalspaghetti at googlemail.com> wrote:

> I'm developing a module at the moment that runs on a cron job.  The
> task of the module at the moment is to get all the  users from the
> drupal database, then connect to a EMS database and insert the users
> into this database.  It allows the site to keep registered users and
> mailing list users in sync.
>
> At the moment, I have the two connection strings in the settings.php file:
>
> $db_url['ems'] = 'mysql://client_ems:client_ems@localhost/client_ems';
> $db_url['default'] = 'mysql://client:client@localhost/client';
>
> $db_prefix = array(
>    'default' => 'main_',
>    'ems' => 'ems_',
> );


More information about the support mailing list