kernelgpf Posted May 18, 2007 Share Posted May 18, 2007 Is it possible to interchangeably query two databases at the same time in the same script, and use+store resources? If so, how? Quote Link to comment https://forums.phpfreaks.com/topic/51931-solved-maintaining-several-different-db-connections-in-same-script/ Share on other sites More sharing options...
calabiyau Posted May 18, 2007 Share Posted May 18, 2007 I've managed to do it before, even with nested loops between two databases..ie..querying one and while looping through the results array using those results to query another and it worked fine. but maybe there is a better way to do that type of thing. Quote Link to comment https://forums.phpfreaks.com/topic/51931-solved-maintaining-several-different-db-connections-in-same-script/#findComment-256013 Share on other sites More sharing options...
kernelgpf Posted May 18, 2007 Author Share Posted May 18, 2007 How did you do it? Quote Link to comment https://forums.phpfreaks.com/topic/51931-solved-maintaining-several-different-db-connections-in-same-script/#findComment-256021 Share on other sites More sharing options...
hvle Posted May 18, 2007 Share Posted May 18, 2007 yeah why not? php is not designed to handle 1 single db connection. In fact, you can have multiple connection to different kind of db, ie. oracle, postgre, myslq ... If you have multiple connection, you must specify which connection to be used when calling db function, otherwise, php will use the first available connection and it could be a wrong one. Quote Link to comment https://forums.phpfreaks.com/topic/51931-solved-maintaining-several-different-db-connections-in-same-script/#findComment-256029 Share on other sites More sharing options...
kernelgpf Posted May 18, 2007 Author Share Posted May 18, 2007 Okay, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/51931-solved-maintaining-several-different-db-connections-in-same-script/#findComment-256031 Share on other sites More sharing options...
calabiyau Posted May 18, 2007 Share Posted May 18, 2007 It was pretty simple actually, just set two different var's to the databases. Select the first one, run your query then within that query select the second one and run your new query. Quote Link to comment https://forums.phpfreaks.com/topic/51931-solved-maintaining-several-different-db-connections-in-same-script/#findComment-256032 Share on other sites More sharing options...
kernelgpf Posted May 18, 2007 Author Share Posted May 18, 2007 Wait... how do you specify which DB variable to use? Quote Link to comment https://forums.phpfreaks.com/topic/51931-solved-maintaining-several-different-db-connections-in-same-script/#findComment-256033 Share on other sites More sharing options...
kernelgpf Posted May 18, 2007 Author Share Posted May 18, 2007 Would I have to connect, query, disconnect, connect to the second DB, query, disconnect, etc.? Quote Link to comment https://forums.phpfreaks.com/topic/51931-solved-maintaining-several-different-db-connections-in-same-script/#findComment-256043 Share on other sites More sharing options...
dj-kenpo Posted May 18, 2007 Share Posted May 18, 2007 disconnect at the bottom of your page when all is said and done. Quote Link to comment https://forums.phpfreaks.com/topic/51931-solved-maintaining-several-different-db-connections-in-same-script/#findComment-256072 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.