Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in PHP only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Today's Posts
Member List
Calendar
Home
Forum
Topic
PHP
using 2 or 3 Databases in PHP!!!
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
Tara83
New Member
Join Date:
Feb 2007
Posts:
11
#1
using 2 or 3 Databases in PHP!!!
Feb 13 '08, 03:32 AM
i'm having this project where i need to be connected to more than 1 database > i've used php before so any redirection to articles or tutorial would be helpful.
thnx for your time
gubbachchi
New Member
Join Date:
Jan 2008
Posts:
59
#2
Feb 13 '08, 07:12 AM
Hi,
You can just use the query in this way,
mysql_query = "SELECT * FROM database1.table 1,database2.tab le2,database3.t able3 WHERE id='1'";
With regards
Comment
Post
Cancel
Tara83
New Member
Join Date:
Feb 2007
Posts:
11
#3
Feb 13 '08, 11:04 AM
thnx for your reply
what about the config file? i still need a new statment to connect to 2 DB
Comment
Post
Cancel
ronverdonk
Recognized Expert
Specialist
Join Date:
Jul 2006
Posts:
4259
#4
Feb 13 '08, 11:10 AM
Originally posted by
Tara83
thnx for your reply
what about the config file? i still need a new statment to connect to 2 DB
See the following entry in the mysql_select_db chapter of the PHP manual
at
multiple dbs
Just incase the mysql_select_db () function still won't work with multiple database connections (as has happened to me before).
$dbh1 = mysql_pconnect( $host,$user,$pa ss);
$dbh2 = mysql_pconnect( $host,$user,$pa ss);
You could do this...
mysql_query("US E database1",$dbh 1);
mysql_query("Us e database2",$dbh 2);
This does the same thing as the mysql_select_db () function...
or this...
You don't even have to select the database for each connection.
mysql_query("SE LECT * FROM database1.table ",$dbh1);
mysql_query("SE LECT * FROM database2.table ",$dbh2);
Ronald
Comment
Post
Cancel
Tara83
New Member
Join Date:
Feb 2007
Posts:
11
#5
Feb 13 '08, 12:22 PM
appreciate your fast help ronverdonk
thnx alot
Comment
Post
Cancel
ronverdonk
Recognized Expert
Specialist
Join Date:
Jul 2006
Posts:
4259
#6
Feb 13 '08, 12:49 PM
Originally posted by
Tara83
appreciate your fast help ronverdonk
thnx alot
You are welcome. See ya again.
Ronald
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment