2

I want to connect to external database:

$old_database = array (
        'default' =>    array (
                'database' => 'grantexpert_registration',
                'username' => 'grantexpert_usr',
                'password' => 'xxxxxx',
                'host' => '62.168.127.59',
                'port' => '5432',
                'driver' => 'pgsql',
                'prefix' => '',
        ),
);

Database::addConnectionInfo('olddatabase', 'default', $old_database);
db_set_active('olddatabase');

But Im getting an error:

Driver not specified for this database connection: olddatabase in Database::openConnection()

All the examples show exactly this structure of array, but it's not working. Is smoething wrong here?

1 Answer 1

3

You've already provided the target DB name with the second param to addConnectionInfo(), so you just need to remove the 'default' element from the array, and shift the connection params up:

$old_database = array (
  'database' => 'grantexpert_registration',
  'username' => 'grantexpert_usr',
  'password' => 'xxxxxx',
  'host' => '62.168.127.59',
  'port' => '5432',
  'driver' => 'pgsql',
  'prefix' => '',
);

Database::addConnectionInfo('olddatabase', 'default', $old_database);
db_set_active('olddatabase');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.