You can write a core database query in magento which is a new stage for managing magento after all
this is a sample of how to write a core query means raw query
<?php echo '<h1> div area</h1>'; $sql = "SELECT sku FROM catalog_product_entity "; $data = Mage::getSingleton('core/resource') ->getConnection('core_read')->fetchAll($sql); if(!$data)echo "empty"; else foreach ($data as $data) echo $data['sku'].'<br/>'; ?>
it show all the sku of your store’s product that means nice.
here i can anatomy the code as
- $sql stands for the query which you want to write
- $data stand for to collect data from the table. Here also come other thing that Mage::getSingleton(‘core/resource’) it is used for connecting the database and getConnection(‘core_read’) is used for connecting mode. That means is it connected as read mode or write mode. And last fetchAll($sql) means fetch all data in data array
- And rest as similar as php.
That’s ok.Have fun…