top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

How to run Custom Query in Magento?

+2 votes
71 views
How to run Custom Query in Magento?
posted Feb 18, 2016 by Vrije Mani Upadhyay

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

****Try this:

$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
$sql        = "Select * from catalog_product_flat_1";
$rows       = $connection->fetchAll($sql); //fetchRow($sql), fetchOne($sql),...
Zend_Debug::dump($rows);

In order to test, you can create sandbox.php file in root of your magento installation and paste the following code:

<?php
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app();
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
$sql        = "Select * from catalog_product_flat_1";
$rows       = $connection->fetchAll($sql); //fetchRow($sql), fetchOne($sql),...
Zend_Debug::dump($rows);

and call from url as:

http://your-magento-url/sandbox.php

answer Aug 9, 2016 by Magento_ocodewire
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...