On 26.06.2008, at 10:46, Bijl, Gomar wrote:
Hi
We have a problem with the (ODBC) persistent database connection. We
have found that every PHP-session, using the same dsn, user and
password, are getting the same persistent connection by a reasonable
chance.
Also meaning that if a database transaction was not finished, other
PHP-session can do a rollback or commit of that transaction.
Right, I presume you are aware of the documentation on this topic,
which affects all rdbms extensions. Just to be sure here is the link:
http://php.net/manual/en/features.persistent-connections.php
To overcome these problems one has to tag the connections. I suggest
to
use a new parameter on ODBC_(p)connect: Tag, a string parameter. If
used
it tries to re-connect to the connection with the same tag, if not
existing it creates a new-connection.
For example the tag parameter is filled with the session_ID() to
ensure
that a connection is bounded to one PHP-session. But also an extension
on this value is possible: (Session_ID() + 'Log') or (Session_ID() +
'Data').
And if somebody does not uses this tag parameter, it works in the old
way, so these solution is downwards compatible.
Several extensions offer a "new_link" optional boolean parameter to
ensure that a new connection is returned if there is already an
existing connection in this request:
http://php.net/mysql_connect
IIRC this "feature" (returning an existing connection link of a
section connection is made to the same server in the same request) is
not present in all extensions, but since ext/mysql was sort of a
template for many extensions, I think a lot of developers copied this
behavior. Note that this parameter is not available in the pconnect
alternatives.
ideally the odbc extension should do a "change user", which would
clean up all the session specific stuff inside the connection (next to
open transactions, there are other stuff like date formats etc that
could also be set). i am not however sure if this feature exists in
all rdbms. afaik the mysql developers are looking to implement this
into mysqlnd.
either way, any solution should try to be consistent across all
affected extensions.
regards,
Lukas Kahwe Smith
[EMAIL PROTECTED]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php