Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect multiple external databases in Magento? [closed]

I need to connect to some external databases from Magento. I found one tutorial to Create an external database connection in Magento. This tutorial was helpful and it worked for connecting to one external database. But, I have to connect more than one external databases.

How can I connect to more than one external databases (suppose 5 external databases) in Magento?

like image 861
Mukesh Chapagain Avatar asked Jan 11 '11 05:01

Mukesh Chapagain


1 Answers

I haven't tested it, but I would expect that duplicating the externaldb_* nodes under global\resources with another (unique) resource name e.g. externaldb2_* should work.

<global>
<resources>
  <externaldb_write>
    <connection>
      <use>externaldb_database</use>
    </connection>
  </externaldb_write>
  <externaldb_read>
    <connection>
      <use>externaldb_database</use>
    </connection>
  </externaldb_read>
  <externaldb_setup>
    <connection>
      <use>core_setup</use>
    </connection>
  </externaldb_setup>
  <externaldb_database>
    <connection>
      <host><![CDATA[localhost]]></host>
      <username><![CDATA[db_username]]></username>
      <password><![CDATA[db_password]]></password>
      <dbname><![CDATA[db_name]]></dbname>
      <model>mysql4</model>
      <type>pdo_mysql</type>
      <active>1</active>
    </connection>
  </externaldb_database>
  <externaldb2_write>
    <connection>
      <use>externaldb2_database</use>
    </connection>
  </externaldb2_write>
  <externaldb2_read>
    <connection>
      <use>externaldb2_database</use>
    </connection>
  </externaldb2_read>
  <externaldb2_setup>
    <connection>
      <use>core_setup</use>
    </connection>
  </externaldb2_setup>
  <externaldb2_database>
    <connection>
      <host><![CDATA[localhost2]]></host>
      <username><![CDATA[db2_username]]></username>
      <password><![CDATA[db2_password]]></password>
      <dbname><![CDATA[db2_name]]></dbname>
      <model>mysql4</model>
      <type>pdo_mysql</type>
      <active>1</active>
    </connection>
  </externaldb2_database>
</resources>

like image 68
Jonathan Day Avatar answered Oct 14 '22 03:10

Jonathan Day