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
See
sales_flat_order.customer_id
Since customer can check out as guest, then customer_id is either null for quest or contain the customer id for register member