I have 3 databases (in addition to the magento one) connected to magento with models (non-eav) defined for the tables.
They all have their read and write connections defined in the local.xml
<cloudvm_db>
<connection>
<host><![CDATA[SERVER]]></host>
<username><![CDATA[USER]]></username>
<password><![CDATA[PASS]]></password>
<dbname><![CDATA[cloudvm]]></dbname>
<model>mysql4</model>
<type>pdo_mysql</type>
<active>1</active>
</connection>
</cloudvm_db>
<cloudvm_read>
<connection>
<use>cloudvm_db</use>
</connection>
</cloudvm_read>
<cloudvm_write>
<connection>
<use>cloudvm_db</use>
</connection>
</cloudvm_write>
then this is defined as the connection for the model in the modules config.xml
<models>
<cloud_workervm>
<class>Cloud_WorkerVM_Model</class>
<resourceModel>cloud_workervm_resource</resourceModel>
</cloud_workervm>
<cloud_workervm_resource>
<class>Cloud_WorkerVM_Model_Resource</class>
<entities>
<virtualmachine>
<table>virtualmachine</table>
</virtualmachine>
</entities>
</cloud_workervm_resource>
</models>
<resources>
<cloud_workervm_write>
<connection>
<use>cloudvm_write</use>
</connection>
</cloud_workervm_write>
<cloud_workervm_read>
<connection>
<use>cloudvm_read</use>
</connection>
</cloud_workervm_read>
</resources>
what I am trying to do is write a function(s) that you can pass the name of a model e.g. "cloud_workervm/cloudvm" and return the name of (or an object of) the read connection and the write connection
Best Answer
Please follow bellow steps
Config.xml
Bellow Read & write function use in model or resource
}