I have to connect with another database in Joomla! that's on another server. To a wordpress plugin and I have to pull some data from the table.
Ok now what I'm not going is by using this database to operate Joomla!, I curently have Joomla! installed and running by itself database on its server but I wish to connect with another database (On The Top from the current one) to drag some data, then disconnect from that third party database - all and keep the initial Joomla database connection in tact.
You are able to connect with an exterior database out of your joomla instance without needing the present ressource of the joomla DB. Do this:
<?php $option = array(); //prevent problems $option['driver'] = 'mysql'; $option['host'] = 'dbase.host.com'; $option['user'] = 'login'; $option['password'] = 'pwd'; $option['database'] = 'anotherdb'; $db = & JDatabase::getInstance( $option ); ?>
I'd same issue before. Fond a good tutorial showing how to connect to multiple database and switch back and forth, additionally, it has sample code. It describes how you can connect with multiple (internal and exterior) databases factory style, without creating multiple connections per request. Which means that should you create database instance in controller same connection is going to be utilized in the model. Enhances performance.
One other good explanation is on Joomla Documentation site [http://paperwork.joomla.org/How_to_connect_to_an_exterior_database].
Are you able to produce a generic mysql-php conection within your wordpress plugin code to produce a connection ? like
//code goes here