I'm on Drupal 6 and I will like to know if there's any API function to get the database name for a Drupal installation.

I'm trying to avoid running a query like this:

db_query("SELECT count(*) FROM information_schema WHERE table_schema = '%s' and table_name = '%s'", $schema, $table);

Thanks

Comments

devtherock’s picture

You can get database url, from that url you can find database name easily

global $db_url;
print $db_url;

Best
Kuldev