wongle Posted June 16, 2022 Share Posted June 16, 2022 Hi there, I am new to PHP / MySQL and I would like to transfer a client's data (ID 223 for example) from the clients table on DB1 to the clients table on DB2. The databases have the same structure and used by two different companies. Can this be done using PHP / MySQL please? I access the client data on a single page using display.php?id=223 Cheers. Quote Link to comment https://forums.phpfreaks.com/topic/314933-copy-client-information-from-one-database-to-another/ Share on other sites More sharing options...
ginerjm Posted June 16, 2022 Share Posted June 16, 2022 Perhaps you should describe the real-life situation here that makes you ask this question. If you have two users who are looking at the same data I have to wonder why you want to duplicate this data rather than adjust your app to properly manage it. Quote Link to comment https://forums.phpfreaks.com/topic/314933-copy-client-information-from-one-database-to-another/#findComment-1597360 Share on other sites More sharing options...
Barand Posted June 16, 2022 Share Posted June 16, 2022 Assuming DB1 and DB2 live on the same server... $pdo->exec("INSERT INTO DB2.client SELECT * from DB1.client WHERE client_id = 223"); Quote Link to comment https://forums.phpfreaks.com/topic/314933-copy-client-information-from-one-database-to-another/#findComment-1597361 Share on other sites More sharing options...
wongle Posted June 16, 2022 Author Share Posted June 16, 2022 4 minutes ago, ginerjm said: Perhaps you should describe the real-life situation here that makes you ask this question. If you have two users who are looking at the same data I have to wonder why you want to duplicate this data rather than adjust your app to properly manage it. Hi there - thanks for your reply, this is because they are 2 separate companies and clients are referred between the 2. Quote Link to comment https://forums.phpfreaks.com/topic/314933-copy-client-information-from-one-database-to-another/#findComment-1597362 Share on other sites More sharing options...
wongle Posted June 16, 2022 Author Share Posted June 16, 2022 3 minutes ago, Barand said: Assuming DB1 and DB2 live on the same server... $pdo->exec("INSERT INTO DB2.client SELECT * from DB1.client WHERE client_id = 223"); Thanks for this, yes, they are on the same server. Quote Link to comment https://forums.phpfreaks.com/topic/314933-copy-client-information-from-one-database-to-another/#findComment-1597363 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.