search
top

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
read more

Queries in Magento

I am describing here the method for executing custom MySQL queries in Magento. <?php //select query $read = Mage::getSingleton('core/resource')->getConnection('core_read'); //make connection $qry = "select name FROM user_data WHERE id=1 LIMIT 1 "; //query $res = $read->fetchRow($qry); //fetch row $name = $res['name']; //outputs name ...
read more

top