Some of you might have worked on Magento.
I am listing here points for connecting another database from Magento.
1) Suppose your database for Magento Project is named ‘magento’.
2) There is one other database named ‘wp’.
3) For using this database inside Magento, you need to setup connection in ‘config.xml’ file which resides in ‘urmagentodirectory/app/etc’
4) In ‘config.xml’ there is a tag ‘’ inside which default connection is setup, you need to write this code under this.
<wp_setup> <connection> <host>< ![CDATA[hostname]]></host> <username>< ![CDATA[username]]></username> <password>< ![CDATA[password]]></password> <dbname>< ![CDATA[wp]]></dbname> <model>mysql4</model> <initstatements>SET NAMES utf8</initstatements> <type>pdo_mysql</type> <active>1</active> </connection> </wp_setup> <wp_write> <connection> <use>wp_setup</use> </connection> </wp_write> <wp_read> <connection> <use>wp_setup</use> </connection> </wp_read>
5) Now you can use this connection by following
<?php $read = Mage::getSingleton('core/resource')->getConnection('wp_read'); $write = Mage::getSingleton('core/resource')->getConnection('wp_write'); ?>