Get Magento’s database configuration

by cliper Tuesday, December 07, 2010 5:58 PM

On Linux, make a php file anywhere in your filesystem while including the magento Mage file.

<?php

require_once "/home/cliper/magento/app/Mage.php";

Mage::app();

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

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

 

 

where /home/cliper/magento/ is your magento absolute path.

In windows, change the directory like:

require_once “C:\magento\path\app\Mage.php”;

You can then use the array like:

echo $dbinfo[“host”];

 

Tags: ,

Code Snippets | Magento | PHP | Tips/Tricks

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



About the author

Author's PhotoI enjoy web developing and would like to share my thoughts of it.

Send mailE-mail me

Most comments

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar