13

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

我该怎么做呢?

4

1 回答 1

29

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'];
于 2012-06-12T07:25:55.213 回答