:confused: hi every one can anyone help me in mysql HOW I CAN LINKE BETWEEN 2 DB WITH PHP OR MORE ?
Printable View
:confused: hi every one can anyone help me in mysql HOW I CAN LINKE BETWEEN 2 DB WITH PHP OR MORE ?
Your post is unclear. We need more information. What does "link" mean?
In short, you can create two different connections and use them as needed. There is nothing specifically difficult about this.
Another question: why do you want to do this? In most cases, it's probably a bad idea. Sometimes (maybe to move information from one database to another) it might be ok, but not as the main way a website is built, probably.
Somewhat related question: Besides what you mentioned what would be a good reason to maintain two databases? The best I can think of is if a person has a very high traffic forum or has a backup database that is used while the primary one is down for updating or fixing so as to ensure that a website never has any downtime due to updates. That is a little beyond me though. I have a friend in IT that explained the usefulness of a backup database to me and that is how I understand it although it is still a bit beyond me.
thunkx
but i was mean like between two table in db with primary key so can we do that between two dbs
Do the tables need to be separate? If so, why? It would be much easier to just put then in the table and use one primary key. Also, please try and use correct English while posting.
keys that link tables to each other areforeign keys, not primary keys.
foreign keys can link 2 or more databases, but only when they're on the same host (or virtual host, or you've gone to some extreme effort to connect them).
Although you could mimic the behavior using PHP, it would be complex and wouldn't work nearly as well as a native implementation.
------------------------------------
As james asked, what are you trying to do?
There's probably a better way to do it.
Now I understand Thank you bernie1227
and by the way I have a weakness in English, so accept my apologies for the construction errors
Specifically:
Are the databases identical (is one a backup for the other, or is it a distributed/ load balanced database), or do the two databases contain different information?
Are the databases on the same host?
If so, are the databases accessible on the same user account?
Then you should be able to use foreign keys normally, as in the link I showed you. Have you tried it?