我试图添加一组新表,并且试图添加外键来链接这些表。我在网上寻找addForeignKey()
可以找到有关的信息,但找不到任何东西。
看着Varien_Db_Adapter_Interface::addForeignKey()
和Mage_Core_Model_Resource_Setup::getFkName()
我想下面的设置我已经得到了正确
->addForeignKey(
$installer->getFkName('namespace_module/shop', 'area_id', 'namespace_module/area','area_id'),
$installer->getTable('namespace_module/shop'),
'area_id',
$installer->getTable('namespace_module/area'),
'area_id',
Varien_Db_Ddl_Table::ACTION_CASCADE,
Varien_Db_Ddl_Table::ACTION_CASCADE
)
但是例外说不一样
Zend_Db_Exception Object
(
[_previous:Zend_Exception:private] =>
[message:protected] => Undefined column "shop_locator_shop"
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => /Users/myname/Sites/site/www/lib/Varien/Db/Ddl/Table.php
[line:protected] => 450
[trace:Exception:private] => Array
(
[0] => Array
(
[file] => /Users/myname/Sites/site/www/app/code/local/Namespace/Module/sql/namespace_module_setup/install-0.1.0.php
[line] => 110
[function] => addForeignKey
[class] => Varien_Db_Ddl_Table
[type] => ->
[args] => Array
(
[0] => FK_SHOP_LOCATOR_SHOP_AREA_ID_SHOP_LOCATOR_AREA_AREA_ID
[1] => shop_locator_shop
[2] => area_id
[3] => shop_locator_area
[4] => area_id
[5] => CASCADE
[6] => CASCADE
)
)
基本上,我该如何向表中添加外键(我已添加了要实现的目标的屏幕截图)