multiple databases ( php and mysql)

multiple databases ( php and mysql)

am 11.06.2006 03:29:52 von Harold

Is it possible to use more than one database ( large web application) on
the same web page
if so how whould i go about it

Thanks in advance

Re: multiple databases ( php and mysql)

am 11.06.2006 06:46:39 von Rik

Harold wrote:
> Is it possible to use more than one database ( large web application)
> on the same web page

Yes. Do you mean more than one database on the same or several servers?

> if so how whould i go about it


Same server, same rights for the user on the 2 db's:
Don't use mysql_select_db()
Use queries like:
SELECT * FROM database1.table

Different servers, or different users
$db1 = mysql_connect($server1,$name1,$pass1);
$db2 = mysql_connect($server2,$name2,$pass2);

And give the resource on queries:
$query_on_db1 = mysql_query($query, $db1);
$query_on_db2 = mysql_query($query, $db2);

Grtz,
--
Rik Wasmus

Re: multiple databases ( php and mysql)

am 11.06.2006 09:27:57 von Shion

Rik wrote:
> Harold wrote:
>> Is it possible to use more than one database ( large web application)
>> on the same web page
>
> Yes. Do you mean more than one database on the same or several servers?
>
>> if so how whould i go about it
>
>
> Same server, same rights for the user on the 2 db's:
> Don't use mysql_select_db()
> Use queries like:
> SELECT * FROM database1.table

> Different servers, or different users
> $db1 = mysql_connect($server1,$name1,$pass1);
> $db2 = mysql_connect($server2,$name2,$pass2);

you can do
mysql_select_db('database1', $db1)
mysql_select_db('database2', $db2)

and you don't have to specify the database name in the queries.


//Aho

Re: multiple databases ( php and mysql)

am 11.06.2006 14:43:56 von Harold

Hello J.O. Aho,

> Rik wrote:
>
>> Harold wrote:
>>
>>> Is it possible to use more than one database ( large web
>>> application) on the same web page
>>>
>> Yes. Do you mean more than one database on the same or several
>> servers?
>>
>>> if so how whould i go about it
>>>
>> Same server, same rights for the user on the 2 db's:
>> Don't use mysql_select_db()
>> Use queries like:
>> SELECT * FROM database1.table
>> Different servers, or different users
>> $db1 = mysql_connect($server1,$name1,$pass1);
>> $db2 = mysql_connect($server2,$name2,$pass2);
> you can do
> mysql_select_db('database1', $db1)
> mysql_select_db('database2', $db2)
> and you don't have to specify the database name in the queries.
>
> //Aho
>


Ok - Thanks to both that responded - BTW it was for same server

Thanks again