I have two databases: firstdb - default drupal installation; seconddb - an external db.

Here is my settings.php:

$db_url['default'] = 'mysqli://root:pwd@localhost/firstdb';
$db_url['second'] = 'mysqli://root:pwd@localhost/seconddb';
$db_prefix = array(
    'default' => 'first_',
    'second'    => 'sec_',
);

But everytime I make a query to a table in the seconddb, I get an error:

user warning: Table 'seconddb.first_tablename' doesn't exist

It should be calling seconddb.sec_tablename. What's wrong with my db_prefix_array?

Comments

prgmctan’s picture

It looks like you might have an extra comma after 'sec_',

Does removing that fix the problem?

Charles Oertel’s picture

Just look at the Drupal Module developers standards - it specifies a comma after every array element, even the last one.

I am unable to help further with the actual problem though, without seeing the code where the db call is being made. It seems to me you have not invoked db_set_active('second'); before issuing the db call.

regards
Charles