I want to get a variable from a table of another module.
I followed this tutorial: https://fishpig.co.uk/magento/tutorials/direct-sql-queries/
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = 'SELECT * FROM ' . $resource->getTableName('catalog/product');
$results = $readConnection->fetchAll($query);
var_dump($results);
and it works great for catalog/product table.
Then I tried to do the same thing for the custom table from a module:
$query = 'SELECT * FROM ' . $resource->getTableName('amtable/rate');
I concluded that the "table name" should be amtable/rate by following this comment and looking at the config.xml:
<global>
<models>
<amtable>
<class>Amasty_Table_Model</class>
<resourceModel>amtable_mysql4</resourceModel>
</amtable>
<amtable_mysql4>
<class>Amasty_Table_Model_Mysql4</class>
<entities>
<method>
<table>am_table_method</table>
</method>
<method_store>
<table>am_table_method_store</table>
</method_store>
<rate>
<table>am_table_rate</table>
</rate>
</entities>
</amtable_mysql4>
But I get an error:
Cannot send headers; headers already sent in app/code/local/Jurgis/Mymodule/controllers/IndexController.php, line 15
Line 15 is: var_dump($results);
What could I be doing wrong or is there something I'm missing?
P.S. sorry about the formatting, couldn't figure out how to fix it.
1 Answer 1
Still not sure what was causing it, but it was fixed by adding exit(); after var_dump($results);
Hope this helps someone.
log?