DecryptWeb Blog

Opensource Web Solutions

Get database connection details in Magento

I am writing here an important code snippet for getting the database connection details used in Magento

$config  = Mage::getConfig()->getResourceConnectionConfig("default_setup");
		$_host = $config->host;
		$_uname = $config->username;
		$_pass = $config->password;
		$_dbname = $config->dbname;
		echo $_host; ///likewise

6 thoughts on “Get database connection details in Magento

    1. where to put this code in magento to get database connection details???

    2. @riya – You can put this in any function in your controller, or for testing you can put in any file (view,model etc)

Comments are closed.

Scroll to top