Multiple Database
Multiple Database
Cont..
To allow multiple database connections, convert $db_url to an array.
<?php $db_url['default'] = 'mysql://drupal:drupal@localhost/drupal; $db_url['mydb'] = 'mysql://user:pwd@localhost/anotherdb'; $db_url['db3'] = 'mysql://user:pwd@localhost/yetanotherdb'; ?>
Cont..
To query a different database, simply set it as active by referencing the key name.
<?php db_set_active('mydb'); db_query('SELECT * FROM table_in_anotherdb'); //Switch back to the default connection when finished. db_set_active('default');
?>
ICT Center
We are making IT happen
Integrity
Commitment
Teamwork