2

Attempting to create an external script that allows me to query some things in Drupal. I was hoping to be able to use my external databases I have defined in the settings of my site to query some of their tables. As one of the databses is Oracle based I have the http://drupal.org/project/oracle module installed.

The following is a PHP script outside of PHP but on the same server (different host):

$_SERVER['HTTP_HOST'] = 'www.example.com';

define('DRUPAL_ROOT','/usr/share/drupal7/');

//require the bootstrap include
require_once DRUPAL_ROOT.'./includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); 
$db1 = Database::getConnection('oracle','external');
$sql = "SELECT * from accounts";
$result = $db1->query($sql);
$accounts = $result->fetchObject();
print_r($accounts);

This code errors with:

PDOException: could not find driver in main() 

The same code (just the Database::getConnection down) running from within a Drupal page works fine. What can I do to make this code execute externally?

Your Answer

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

Browse other questions tagged or ask your own question.