Page 1 of 1

Search different databases

Posted: Sun May 15, 2005 12:47 am
by Maluendaster
hey, i want to do a search from different databases (it's the same for all of them), is for an automotive site.. Is there anyway I can merge in a search and search like 100 databases and display the resulst???

Posted: Sun May 15, 2005 3:32 am
by phpScott
not in one search as each db will have it's own username and password which is required in order to make the connection to be able to query it.

Posted: Sun May 15, 2005 12:33 pm
by Maluendaster
phpScott wrote:not in one search as each db will have it's own username and password which is required in order to make the connection to be able to query it.
all the databases have the same user/password...

Posted: Sun May 15, 2005 12:51 pm
by John Cartwright
nonetheless, you are going to have to loop through each database, and select it.

Code: Select all

$db = array('127.0.0.1' => 'some_database',
            '127.0.0.2' => 'a_database') ;

foreach ($db as $host => $new_db)
{
     mysql_connect($host,$user,$pass) or die(mysql_error());
     mysql_select_db($new_db);

     //run search here
}
I have never heard of any "easy" way to access multiple databases concurantly.

Posted: Sun May 15, 2005 1:14 pm
by Pyrite
Is it > 1 database on the same MySQL server? Or numerous database engines? If it is just the same server, using mysql_select_db in a loop. Otherwise, ADOdb might come in handy.