Hello
I'm implementing drupal in such a fashion that multiple (non-drupal) databases are queried.

I'm having a problem getting the FALSE return value if a db_set_active($name) is attempted when $name does not exist in the setting file . Essentially, the lack of a FALSE return value prevents us from knowing if we connected.

This is might be a bug in the core function or my usage of postgres. Currently I simply solve it through a function that was making the connection

sub connect_my_db($name=NULL){
#reset to Drupal. call it after finishing with secondary DB
if (empty($name){
 db_set_active('default');
}
  global $db_url;
if (empty ($db_url[$name])){ 
   drupal_set_message('The public database is unavailable at the time.','error','FALSE');
   return FALSE;
}else {
 db_set_active($name);
 return TRUE;
 }
}

I 've tested that this indeed works with databases not/wrongly specified in the settings file.

cheers
alexie

Comments

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.