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

Get table prefix in Magento

Hello All, I am writing here an important code snippet for getting the table prefix (if any defined) in Magento. $prefix = Mage::getConfig()->getTablePrefix(); echo $prefix;
read more

Get Table Name in Magento

I am writing here a small but useful snippet of code, for getting the table name of any module (whose table name are defined in config file). This is very useful when using joins in query. Suppose my module is ‘vendor’. <?php $resource = Mage::getSingleton('core/resource'); $tableName = $resource->getTableName('vendor/vendor'); ?>
read more

Filters in Query in Magento

Hello All, When we are filtering data in Magento, time occurs when we want to fetch result after filters like Not equal, greater than, less than, etc. The addFieldToFilter method’s second parameter is used for this. It supports an alternate syntax where, instead of passing in a string, you pass in a single element Array. The key of this array is the type of comparison you want to make. The value...
read more

Insert and Retrieve file with MySQL

Some of you might be knowing that there is a functionality in MySQL database for storing files and retrieving the same. This is mainly used when we need to reduce response time for retrieving and using files in our application. I am listing here the method for inserting image file in and retrieving image file from MySQL database using PHP. 1) For inserting data into MySQL you need to convert the image...
read more

Get Database Prefix

I am listing an example for retrieving the Joomla database prefix. <?php $db =& JFactory::getDBO(); //Returns a reference to the global database object echo "Database prefix is : " . $db->getPrefix(); //output will be something like this Database prefix is : jos_ ?>
read more

Joomla essentials

Joomla is a very great CMS. I am listing below important variable used in joomla. JPath is used to get the directory path. DS — is used as a directory separator. JPATH_ADMINISTRATOR– Sets the path to /Joomla/administrator JPATH_BASE — sets the entry to joomla /Joomla JPATH_CACHE –Sets the cache path /Joomla/cache JPATH_COMPONENT — Sets the component path /Joomla/components/com_example JPATH_COMPONENT_ADMINISTRATOR...
read more

Connect different database from Magento

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

top