trying to set up a config file for a custom module - do I need to have a unique model for each 'resourceModel', or is it possible to have multiple table entities per model?
Is it possible to get something like this to work:
<config>...
<model>
<namespace>
<class>Namespace_Module_Model</class>
<resourceModel>module_mysq4</resourceModel>
</namespace>
<module_mysql4>
<class>Namespace_Module_Model_Mysql4</class>
<entities>
<table_1>
<table>table_1</table>
</table_1>
<table_2>
<table>table_2</table>
</table_2>
<table_3>
<table>table_3</table>
</table_3>
...
</entities>
</module_mysql4>
..</config>
and then dynamically switch between the tables through the model?
and related: Anyone know what the possible children of the are and their properites? I've seen 'entities', 'associations' and 'items' - thx
It's not really clear what you're asking here. Magento has a basic one resource to one table resource, and a one resource to many tables constructed in a specific manner resource for EAV style models.
The scenario you're describing above isn't directly supported by the system, but if you wanted to implement something like it there's nothing stopping you from implementing a resource that works any way you want.
As for the possible children, create the simple config viewer described here to get a dump of the entire merged config, and then use an xpath viewer to examine all the nodes (and their children) that you're interested in
Thx for the response & apologies if the question was unclear. After a few hours of debugging, I have it working with the following structure:
<models>
<modulename>
<class>Namespace_Modulename_Model</class>
<resourceModel>modulename_mysql4</resourceModel>
</modulename>
<modulename_type1>
<class>Namespace_Modulename_Model_Type1</class>
<resourceModel>modulename_mysql4</resourceModel>
</modulename_type1>
<modulename_type2>
<class>Namespace_Modulename_Model_Type2</class>
<resourceModel>modulename_mysql4</resourceModel>
</modulename_type2>
<modulename_mysql4>
<class>Namespace_Modulename_Model_Mysql4</class>
<entities>
<modulename>
<table>modulename</table>
</modulename>
<modulename_type1>
<table>modulename_type1</table>
</modulename_type1>
<modulename__type2>
<table>modulename_type2</table>
</modulename_type2>
</entities>
</modulename_mysql4>
</models>
So yes - there is a single table entity for each model declared (one model, one resource) but I would have assumed that each additional model/resourceModel combination would require it's own separate Model_Mysql class in it's own modulename_mysql4 node, ala:
<models>
<modulename>
<class>Namespace_Modulename_Model</class>
<resourceModel>modulename_mysql4</resourceModel>
</modulename>
<modulename_type1>
<class>Namespace_Modulename_Model_Type1</class>
<resourceModel>modulename_mysql4_type1</resourceModel>
</modulename_type1>
<modulename_type2>
<class>Namespace_Modulename_Model_Type2</class>
<resourceModel>modulename_mysql4_type2</resourceModel>
</modulename_type2>
<modulename_mysql4>
<class>Namespace_Modulename_Model_Mysql4</class>
<entities>
<modulename>
<table>modulename</table>
</modulename>
</entities>
</modulename_mysql4>
<modulename_mysql4_type1>
<class>Namespace_Modulename_Model_Mysql4_Type1</class>
<entities>
<modulename_type1>
<table>modulename_type1</table>
</modulename_type1>
</entities>
</modulename_mysql4_type1>
<modulename_mysql4_type2>
<class>Namespace_Modulename_Model_Mysql_Type2</class>
<entities>
<modulename_type2>
<table>modulename_type2</table>
</modulename_type2>
</entities>
</modulename_mysql4_type2>
</models>
but that is not the case. Would love to hear a play by play explanation. Thx for the help!
Or:
<resources>
<modulename_setup>
<setup>
<module>modulename</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</modulename_setup>
<modulename_write>
<connection>
<use>core_write</use>
</connection>
</modulename_write>
<modulename_read>
<connection>
<use>core_read</use>
</connection>
</modulename_read>
</resources>