Magento Coding Solutions

programaticaly Insert and select quary In magento

    
 INSERT QUERY

include('../app/Mage.php');
Mage::app();

$write = Mage::getSingleton('core/resource')->getConnection('core_write');
$sql="INSERT INTO opd_uploads SET extension='$extension', sessionId='$sessionId', ip='$ip', status=1, dateTime=now()";
$write->query($sql);
//lastInserted ID
$imageId = $write->lastInsertId();


SELECT QUERY

$read= Mage::getSingleton('core/resource')->getConnection('core_read');
       
         $value=$read->query("select * from opd_uploads WHERE id='".$imageRowId."'");
         $row = $value->fetch();
         $orgFilExt=$row['extension'];
       

Get store data Magento

Get store data
Mage::app()->getStore();
Store Id
Mage::app()->getStore()->getStoreId();
Store code
Mage::app()->getStore()->getCode();
Website Id
Mage::app()->getStore()->getWebsiteId();
Store Name
Mage::app()->getStore()->getName();
Is Active
Mage::app()->getStore()->getIsActive();
Store Home Url
Mage::app()->getStore()->getHomeUrl();