• ABOUT THIS SITE
  • MY CV
  • MY SOCIAL STREAM
  • CONTACT
  • SEARCH

olav.net

  • content
  • technology
  • life
  • bonn
Home

Note to self: Use db_set_active() to switch databases in Drupal

olav — Wed, 08/20/2008 - 13:00

If you use Drupal as a toolbox to implement a nice admin interface and your database administrator gets annoyed about the many tables Drupal uses, you can bracket your database code with calls to db_set_active(‘mydb’) like so:


db_set_active(‘mydb’);
// code that uses your existing database
db_set_active(‘default’);

In your sites/default/settings.php, you need to make $db_url an array like so:

$db_url = array(
  'default' => 'mysql://your:drupal@tables.live/here',
  'mydb' => 'mysql://all:your@other.tables.are/here',
);
  • Drupal
  • master / slave databases
  • Add new comment

I can't get this to work

Anonymous — Thu, 04/02/2009 - 00:40

I can’t get this code to work for me. I put my php code in a block and the block doesn’t return any data. Could you supply a working example. I can send you my code if you want to look it over.

  • reply

Praxiswissen Drupal 6. oreillys basics

Mein Buch ist erschienen:

Image of Praxiswissen Drupal 6. oreillys basics

Hier ist die Zusammenfassung.

Hm, lecker!

Selber Punkte verschicken oder sammeln unter browniepunkt.de.

Mitglied der Drupal Association

Kreativ mit Elektronik

Basteln mit Elektronik, Arduino, PICAXE, kombiniert mit Malerei, Textilien, Holz oder Metall können Eltern und Kinder regelmäßig bei meinen Workshops. Nächster Termin: 3./4.4.2012 im Deutschen Museum in Bonn . Ein kleines Side Project war der Benzoltisch im Deutschen Museum im Bonn.

Wir sind alle Atheisten

... in Bezug auf die meisten Götter, an die die Menschheit jemals geglaubt hat. Manche von uns gehen einfach noch einen Gott weiter – Richard Dawkins.

Das Syndicat

Unter syndikate.it blogge ich über Cloud-Technologien. Dort gibt es auch Links zu meinen anderen Websites .

Navigation

  • Recent posts

User login

What is OpenID?
  • Log in using OpenID
  • Cancel OpenID login
  • Create new account
  • Request new password

Kommentiert

  • vimax comprar
    5 days 20 hours ago
  • vimax funciona
    5 weeks 1 day ago
  • Wenn dieses Framework nichts
    25 weeks 3 days ago
  • Kindle version of book
    27 weeks 17 hours ago
  • Susanna
    27 weeks 1 day ago
  • Tami
    30 weeks 6 days ago
  • Anti-Glare?
    1 year 11 weeks ago
  • Ein erstes Release des CakePHP-Frontends für TYPO3
    1 year 33 weeks ago
  • Geniuos!
    1 year 41 weeks ago
  • Mobile
    2 years 5 days ago

Freunde

Powered by Drupal, an open source content management system
  • content
  • technology
  • life
  • bonn