How to get the current active DB in Drupal 6?
Doesn't look like drupal allows it inherently, so I'm posting my hack in the meantime. I'm open to any suggestions on improving this:

global $db_url;
$activeDBName = db_result(db_query('select database()'));
$mode = '';
foreach ($db_url as $key =&gt; $url) {
    if(strpos($url, $activeDBName) !== FALSE) {
        $mode = $key;
    }
}


$mode will then be whatever the active db is.