Create a custom Database connection in Magento

Create a connect.php file in root folder. and past the below code . now you are able to access Data base on this file.



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"];
$con = mysql_select_db($dbname,mysql_connect($hostname,$user,$password));

Leave a Reply