Maintaining an open database connection?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
tatlar
Forum Newbie
Posts: 7
Joined: Tue Feb 24, 2004 6:18 pm
Location: Surfside

Maintaining an open database connection?

Post by tatlar »

Hello,

We have a proprietary database which we can connect to through a C-callable dynamic load library. Opening a connection to this database returns a small array variable (four integers), i.e. a database handle, which we can use to manage the connection.

We want to open one of these database connections via a PHP-driven web-page, interact with the database handle in a series of operations, and then exit.

In order to do this we have wrapped a mod_php dynamically-loadable module around the database library, giving us the following cascade:

Proprietary database shared-object library
PHP dynamically-loadable wrapper
mod_php4
apache
PHP scripts referencing the database handle

The question is, what do we need to do to make sure that during a single set of user interactions with this database, modifications and requests to the database four-integer handle are always interacting with the same instance of the proprietary database-connection library?

This must have something to do with PHP sessions and/or persistent connections but other than that we're lost.

Thanks!
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Try to pm Volka ( profile.php?mode=viewprofile&u=185 ). It's quite a few people able to help you here, and I believe he's one of them.
User avatar
tatlar
Forum Newbie
Posts: 7
Joined: Tue Feb 24, 2004 6:18 pm
Location: Surfside

Post by tatlar »

Thanks Weirdan - I pm'ed Volka.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

...and I'm taking it back to this thread since I skate on thin ice ;)

Apparently you want something like mysql_pconnect, but with one extension that is explicitly pointed out not to be supported, see: http://php.net/manual/en/features.persistent-connections.php. To my knowledge there is (atm) no reliable way to circumvent this restriction for reasons explained in this document as long as http is the transport layer. This is also true for your module.

Although http/1.1 defines a way to keep a connection between client and server alive between two requests, that -in theory- makes it possible to bind resources to a connection throughout a session, this has no practical meaning for php.

Do you want to implement/use some kind of transaction mechanism and therefor need not to close the database connection until the transaction is either comitted or aborted?
User avatar
tatlar
Forum Newbie
Posts: 7
Joined: Tue Feb 24, 2004 6:18 pm
Location: Surfside

Post by tatlar »

Do you want to implement/use some kind of transaction mechanism and therefor need not to close the database connection until the transaction is either comitted or aborted?

Yes. We want to conduct multiple transactions on the same connection
without closing it. Thanks for the feedback. Any ideas would be appreciated...
User avatar
tatlar
Forum Newbie
Posts: 7
Joined: Tue Feb 24, 2004 6:18 pm
Location: Surfside

Post by tatlar »

Any ideas for this thread? Volka? Anyone?
Post Reply