how to render content from two databases

Events happening in the community are now at Drupal community events on www.drupal.org.
bharathkanichar's picture

i have two websites installed on two different databases,now i want to
create a view from these two data bases and show as a home page

Comments

Solution

cr0ss's picture

First of all these two bases should be Drupal databases.

Second, settings.php file should be like that:
$db_url['default'] = 'mysql://username:password@localhost/databasename1';
$db_url['second_base'] = 'mysql://username:password@localhost/databasename2';

Third, it`s actually code:

<?php

  $first_view
= views_embed_view('view_name_from_first_base', 'display_name');

 
db_set_active('second_base');
 
$second_view = views_embed_view('view_name_from_second_base', 'display_name');

 
db_set_active('default');

 
$output = $first_view . $second_view;

 
// TODO: theming, etc...
?>

Although this could work, you should check everything correctly to get rid of any errors.

Multisite

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: