Welcome Guest, Not a member yet? Register   Sign In
Multiple database + pconnect issues
#30

[eluser]bAum[/eluser]
It seems that we are talking about two different problems here, let me clarify Smile

What I meant is that having an object for each databse (being able to say $db1->query() and $db2->query()) is very convenient. It is, however, not possible with the usual connection parameters if these two databases happen to be on the same mysql/postgres/.. server.

In that case the connection function will refuse to connect to the same server twice, and so $db1 and $db2 are actually the same. This means that in your code, you explicitly need to change the active database each time you alternate between $db1 and $db2 (by issuing a USE query first). While this might be more optimal, since you have only one open connection instead of two, it will mess up your code if you alternate between $db1 and $db2 very often.

Instead, you can force a reconnect and you'll end up with two connections to the same database server but on different databases ($db1 and $db2 are different). This might be considered a waste of performance, but now your $db1 and $db2 can be used transparently, without the need of clunking your code with USE queries.

A third solution would be to rewrite the db connection driver like the guys at the start of the thread did, but well, you need to do it, you need to maintain it and so on..


As for the persistent connections you are talking about, I am not sure how that affects the "different databases on same database server" issue I just described. The mysql_pconnect method also has the force reconnect parameter, which suggests that it works the same way. However, that doesn't make sense to me, since the doc says that a persistent connection is identified by host, username and password only (not the active database).


Messages In This Thread
Multiple database + pconnect issues - by El Forum - 02-20-2008, 10:16 PM
Multiple database + pconnect issues - by El Forum - 02-21-2008, 06:10 AM
Multiple database + pconnect issues - by El Forum - 02-21-2008, 09:51 AM
Multiple database + pconnect issues - by El Forum - 02-21-2008, 10:33 AM
Multiple database + pconnect issues - by El Forum - 02-21-2008, 02:19 PM
Multiple database + pconnect issues - by El Forum - 02-21-2008, 03:47 PM
Multiple database + pconnect issues - by El Forum - 02-21-2008, 04:25 PM
Multiple database + pconnect issues - by El Forum - 02-21-2008, 04:39 PM
Multiple database + pconnect issues - by El Forum - 02-21-2008, 05:00 PM
Multiple database + pconnect issues - by El Forum - 02-21-2008, 05:20 PM
Multiple database + pconnect issues - by El Forum - 02-21-2008, 05:25 PM
Multiple database + pconnect issues - by El Forum - 02-21-2008, 05:40 PM
Multiple database + pconnect issues - by El Forum - 02-21-2008, 06:16 PM
Multiple database + pconnect issues - by El Forum - 02-21-2008, 06:47 PM
Multiple database + pconnect issues - by El Forum - 02-21-2008, 06:58 PM
Multiple database + pconnect issues - by El Forum - 02-21-2008, 07:04 PM
Multiple database + pconnect issues - by El Forum - 02-21-2008, 07:14 PM
Multiple database + pconnect issues - by El Forum - 02-21-2008, 07:24 PM
Multiple database + pconnect issues - by El Forum - 02-21-2008, 07:39 PM
Multiple database + pconnect issues - by El Forum - 05-01-2008, 08:48 AM
Multiple database + pconnect issues - by El Forum - 05-19-2008, 09:35 PM
Multiple database + pconnect issues - by El Forum - 05-20-2008, 06:26 AM
Multiple database + pconnect issues - by El Forum - 06-11-2008, 09:39 AM
Multiple database + pconnect issues - by El Forum - 06-11-2008, 02:19 PM
Multiple database + pconnect issues - by El Forum - 07-28-2008, 02:47 AM
Multiple database + pconnect issues - by El Forum - 07-28-2008, 03:06 AM
Multiple database + pconnect issues - by El Forum - 07-28-2008, 09:24 PM
Multiple database + pconnect issues - by El Forum - 07-29-2008, 01:11 AM
Multiple database + pconnect issues - by El Forum - 07-29-2008, 07:07 PM
Multiple database + pconnect issues - by El Forum - 07-30-2008, 02:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB