If your model extends Mage_Core_Model_Abstract
and your resource model is configured correctly you should be able to load the row like this:
$model = Mage::getModel('prefs/prefsemail')->load($id);
Then all your columns should be found in $model->getData()
EDIT
If you want to get data from an other table using a FK try this:
$collection = Mage::getModel('prefs/prefsemail')->getCollection()->addFieldToFilter('fk_name', $fkValue);
foreach ($collection as $item){
//do something with $item
}
Try it like this:
->addForeignKey(
$installer->getFkName('namespace_module/shop', 'area_id', 'namespace_module/area','area_id'),
'area_id',
$installer->getTable('namespace_module/area'),
'area_id',
Varien_Db_Ddl_Table::ACTION_CASCADE,
Varien_Db_Ddl_Table::ACTION_CASCADE
)
The difference in my code is that I removed the first line below getFkName
.
since you are calling addForeignKey
on a table while creating it, you don't need to specify it's name again.
as a general rule use:
->addForeignKey(
$installer->getFkName('TABLE ALIAS', 'FK_FIELD', 'REF_TABLE_ALIAS','REF_TABLE_FIELD'),
'CURRENT_TABLE_FIELD_NAME',
$installer->getTable('REF_TABLE_ALIAS'),
'REF_TABLE_FIELD',
Varien_Db_Ddl_Table::ACTION_CASCADE,
Varien_Db_Ddl_Table::ACTION_CASCADE
)
[Edit]
You should be looking at Varien_Db_Ddl_Table::addForeignKey
because you are using it on an instance of Varien_Db_Ddl_Table
.
Best Answer
Ya, we can set foreign key check as disable before importing database into phpmyadmin.
What we need to do is, edit that database file i.e. yourdatabase.sql and add 2 lines in it.
1) Add in just beginning of database file
2) Just before end of file at last line of file.
First it will disable foreign key checks and in the end, it will enable it again.