如何获取magento数据库详细信息

时间:2012-06-12 07:17:08

标签: php magento

我想在magento中的任何文件中获取magento的数据库配置。

我该怎么做?

1 个答案:

答案 0 :(得分:28)

Magento连接细节你可以找到以下方法..........

require_once ('../app/Mage.php');
$app = Mage::app('default');

$config  = Mage::getConfig()->getResourceConnectionConfig('default_setup');

$dbinfo = array('host' => $config->host,
            'user' => $config->username,
            'pass' => $config->password,
            'dbname' => $config->dbname
);

$hostname = $dbinfo['host'];
$user = $dbinfo['user'];
$password = $dbinfo['pass'];
$dbname = $dbinfo['dbname'];