Using multiple databases with Drupal
Using an external database with Drupal is very simple.
First, you must add the database to your settings.php file like so:
$db_url['default'] = 'mysqli://user:password@localhost/database_name';
$db_url['external'] = 'mysqli://user:password@localhost/database_name';
So, “default” is our regular Drupal database and “external” is an additional database. To switch to the “external” database, you would use this code:
db_set_active('external');
//Your code here
//*****then remember to SWITCH BACK TO DEFAULT DATABASE when done
db_set_active('default');
Easy as Pie!
| Print article | This entry was posted by Raymond on April 18, 2010 at 6:21 am, and is filed under Drupal. Follow any responses to this post through RSS 2.0. Both comments and pings are currently closed. |
Comments are closed.
about 3 months ago
My cousin recommended this blog and she was totally right keep up the fantastic work!