get resource of magento programatically

<?php
require_once 'app/Mage.php';
umask(0);
Mage::app('default');
$resource = Mage::getConfig()->getNode('global/resources')->asArray();
echo '<pre>';
print_r($resource);
echo '</pre>';
$db_host = $resource['default_setup']['connection']['host'];
$db_user = $resource['default_setup']['connection']['username'];
$db_pass = $resource['default_setup']['connection']['password'];
$db_name = $resource['default_setup']['connection']['dbname'];

echo '<br />host : '.$db_host;
echo '<br />username : '.$db_user;
echo '<br />password : '.$db_pass;
echo '<br />dbname : '.$db_name;
?>

Share on Facebook