I am working with Drupal 7.3.4 and attempting to follow the instructions of changing settings.php so that I can switch to a pgsql DB within a module and then switch back to the default mysql after doing a query.
I have set up in the settings.php file with the following format:
$databases = array ( 'default' => array ( 'default' => array ( 'database' => '', 'username' => '', 'password' => '', 'host' => 'localhost', 'port' => '', 'driver' => 'mysql', 'prefix' => '', ), ), 'custom_db' => array ( 'default' => array ( 'database' => 'custom_db', 'username' => 'dbuser', 'password' => 'pass', 'host' => 'urltoservice', 'port' => '5432', 'driver' => 'pgsql', 'prefix' => '', ), ), );
Now I am trying the process of switching to this DB in a module and verifying that the driver is changing.
db_set_active('custom_db'); //Get the currently active DB driver drupal_set_message(db_driver()); db_set_active();
But, when I print the driver it is not switching to pgsql as expected. I am pretty sure it is still pointing to the default mysql db. Any ideas of what I may be doing wrong here would be greatly appreciated.