Refiking
Refiking

Reputation: 641

How Can I Retrieve the DB settings on Joomla?

I need to retrieve the mysql connection settings and store them as variables. I know that the file configuration.php contains what I need. I just don't know how to call it accurately. Here are the 4 variables (and associate values) that I need:

1) $host = public $host from config file 2) $user = public $user from config file 3) $password = public $password from config file 4) $db_name = public $db from config file

Upvotes: 0

Views: 255

Answers (1)

Tarek
Tarek

Reputation: 3798

$info =& JFactory::getApplication();

$info->getCfg('host'); 
$info->getCfg('user'); 
$info->getCfg('db'); 


// defined in libraries/joomla/application/application.php (380)
function getCfg( $varname ) {
    $config =& JFactory::getConfig();
    return $config->getValue('config.' . $varname);
}

looking at the code in joomla application you can also do the following :

$config =& JFactory::getConfig();

and get most if the info you want .

Upvotes: 1

Related Questions