Page 1 of 1

Maintaining an open database connection?

Posted: Tue Mar 09, 2004 12:33 pm
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!

Posted: Wed Mar 10, 2004 1:58 pm
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.

Posted: Wed Mar 10, 2004 2:06 pm
by tatlar
Thanks Weirdan - I pm'ed Volka.

Posted: Wed Mar 10, 2004 9:48 pm
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?

Posted: Thu Mar 11, 2004 11:53 am
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...

Posted: Wed Mar 17, 2004 6:17 pm
by tatlar
Any ideas for this thread? Volka? Anyone?