Saturday, 13 January 2018

How to run Custom Mysql Query in Magento

How to run Custom Mysql Query in Magento

Created a test file( abc.php) in my magento root folder & written a custom query on this file.

<?php
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app();
$i = 1;


$connection = Mage::getSingleton('core/resource')->getConnection('core_read');

$sql  = "SELECT `e`.* FROM `customer_entity` AS `e` WHERE (`e`.`entity_id` = '12')";

$collection       = $connection->fetchAll($sql);

?>

No comments:

Post a Comment

Magento Cache System Basic Concepts

The Basics – How To Use Cache In this section we will see how to use cache in our custom modules. Suppose you have a custom module and w...