1

my Drupal 6 installation is on a MySql server, while my own custom database is on Oracle. I have made a custom module that can read and write data into my external database, but i would like to use Views module to handle the data to show. I know that I can programmatically build views, but i don't know if I can build one for Oracle DB while Drupal is on Mysql.

1

You can create a view to a non-drupal table/database but you need to create a connection to it first using either one of the two connector modules: the Data module or the Table Wizard module.

You can also set it up using the Views API with views_hook_data(). (See documentation on views/help/api-tables.html.)

You'll need to add your new database connection settings in your settings file.

// In settings.php for your site
// Your drupal (site) database needs to be called 'default'
$db_url['default'] = 'mysqli://user:pass@host/drupal_db';
$db_url['oracle_db'] = 'mysqli://user:pass@host/other_db';

Then, in your view hook, define the tables the view should have access to.

$data[$table]['table']['base'] = array(
    'field' => 'Primary key',
    'title' => t('Field name'),
    'help' => t('Field description'),
    'database' => 'oracle_db',
    'weight' => -10,
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.