function dba_get_database in Database Administration 5
Return name of active database.
Related topics
3 calls to dba_get_database()
File
- ./
dba.module, line 1324 - Allows administrators direct access to their Drupal database. Written by Jeremy Andrews <jeremy@kerneltrap.org>, June 2004. PostgreSQL functionality provided by AAM <aam@ugpl.de> Major security audit, porting, and maintenance by Derek…
Code
function dba_get_database() {
static $database = array();
if ($database) {
// Cache copy so function can be called multiple times efficiently.
return $database;
}
if (_is_mysql()) {
$database = array_keys(db_fetch_array(db_query('show tables')));
$database = preg_replace('/^Tables_in_/', '', $database[0]);
}
else {
$result = db_fetch_object(db_query('SELECT DISTINCT dbname FROM {drupal_system_catalog} LIMIT 1'));
$database = $result->dbname;
}
return $database;
}