This is a discussion on Apache2, php and threads within the Linux Web Servers forums, part of the Web Server and Related Forums category; Hello, i am plannung to develop a web application (actually an online game). I have learned that php may use ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello,
i am plannung to develop a web application (actually an online game). I have learned that php may use c++ classes from a shared library and want to use this feature. I want to use apache2 and php 4.3. So i think it is a good idea to make db accesses (to a mysql db) from c++ to load objects from the db. My question is: how to i handle the db connections? I think it is a good idea to implement a static object inside the shared c++ library. In its constructor the db connection is established. In its destructor the db connection is shut down. When the php script loads my shared c++ library the static object is created, its constructor is called and the db connection is established. When unloading the library the static object is destroyed, its destructor is called and the db connection is shut down. Is this a good idea? I wonder how often my shared library will be loaded and unloaded. Will it be loaded and unloaded for each execution of my php script? Or will it be loaded once only and stays in memory for a certain time? Is there one process for each php script execution? Is the process shut down after the php script exits or does the process execute not only one, but many php scripts? Is there a difference of using php's dl command to load my shared library to compiling my shared library into php as an extension? How many threads will use the shared library? Has it to be thread safe? Is it wise to establish a pool of db connection inside the library? Perhaps these questions are stupid. If there is an easy solution for the problem of db access from a shared c++ library used in a php script please let me know. Thank you very much. Best regards, Christian Neise. |
| Thread Tools | |
| Display Modes | |
|
|