Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Get Data from database using $write->query
 
partha
Jr. Member
 
Total Posts:  13
Joined:  2008-09-07
 

I like to display data in .phtml page. How can I fetch data after running select query in $write->query() function?. Can any body help?.

 
Magento Community Magento Community
Magento Community
Magento Community
 
roshanlal
Member
 
Avatar
Total Posts:  33
Joined:  2010-01-15
india
 

$tableName = Mage::getSingleton(’core/resource’)->getTableName(’TABLE NAME’);

// if prefix was ‘mage_’ then the below statement
// would print out mage_catalog_product_entity
echo $tableName;

$write = Mage::getSingleton(’core/resource’)->getConnection(’core_write’);

//echo ‘<pre>’;
//print_r(get_class_methods($write));
//echo ‘</pre>’;

$query = “Write Query”;
$write->query($query);

 
Magento Community Magento Community
Magento Community
Magento Community
 
Seven Codes
Jr. Member
 
Avatar
Total Posts:  13
Joined:  2011-03-23
 

hiiiiiiiii all,

here is a small code block that i used in .phtml file to pull data from table... it work for me... LOL

------------------------------
$connection = Mage::getSingleton(’core/resource’)->getConnection(’distributor_read’); //I assuming that you created the model for your table
$result = $connection->fetchAll("SELECT filedname FROM tablename WHERE condition");

///just checking the result
print_r($result);
------------------------------

regards
Roshan Joseph

 
Magento Community Magento Community
Magento Community
Magento Community
 
Seven Codes
Jr. Member
 
Avatar
Total Posts:  13
Joined:  2011-03-23
 

Hiiiiiii All,

here is another thread:  LOL

How to fetch data from custom table in magento......
http://sanjeevkumarjha.com.np/how-to-fetch-data-from-custom-table-in-magento/

regards
Roshan Joseph

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top