【发布时间】:2012-02-24 05:31:06
【问题描述】:
我是 Magento 的新手。我的自定义模块中需要两个表,我必须加载两个表作为单独的集合,即Mage::getModel('mymodule/model1')->getcollection() 和Mage::getModel('mymodule/model2')->getcollection()
我已点击此处发布的链接Magento - possible to have multiple tables for a single model?,但我被卡住了。我创建了两个模型类“model1”和“model2”,并在“mysql4”下创建了相同的模型,我的第一个模型工作正常,但如果我访问第二个模型就无法正常工作。
如何在一个模块中使用多个表?
提前致谢。
这是我的 config.xml
<models>
<module>
<class>Package_Module_Model</class>
<resourceModel>module_mysql4</resourceModel>
</module>
<module_type1>
<class>Package_Module_Model_Type1</class>
<resourceModel>module_mysql4</resourceModel>
</module_type1>
<module_mysql4>
<class>Package_Module_Model_Mysql4</class>
<entities>
<module>
<table>table1</table>
</module>
<module_type1>
<table>table2</table>
</module_type1>
</entities>
</module_mysql4>
【问题讨论】:
-
是的,当然。你在模型的 _init 方法中使用了什么?
-
我认为您的资源模型或其调用存在问题
-
像 $this->_init('mymodule/model2');
-
我在 mysql4 文件夹下也为第二个创建了资源模型
-
资源模型中的init方法呢?
标签: database magento entity-attribute-value