Database Connections In Magento

By default, Magento will automatically connect to it’s database and provide two separate resources which you can use to access data: “core_read” and “core_write”.

<?php	
	/**
	 * Get the resource model
	 */
	$resource = Mage::getSingleton('core/resource');
 
	/**
	 * Retrieve the read connection
	 */
	$readConnection = $resource->getConnection('core_read');
 
	/**
	 * Retrieve the write connection
	 */
	$writeConnection = $resource->getConnection('core_write');

Leave a Reply