Jump to content

singleton class


AP81

Recommended Posts

Hi,

 

I am designing a new database class (connection, query, etc) and was thinking of making it a singleton class to save on resources. 

 

My question is, if I have two PHP pages concurrently performing a database query (using this singleton class), will the database queries be interrupted due to having only one instance of the class?

Link to comment
Share on other sites

regardless of how you structure your OOP it still is going to need to use the mysql function library i.e mysql_query mysql_fetch_assoc, mysql_num_rows etc.  Those functions all depend on your mysql config in how they function so the singleton idea fails because mysql allow multiple concurrent connections.  In addition classes don't carry across pages beautifully as you would expect.

 

In conclusion if you really want to redesign mysql to work in an OOP function just build it to help you, and don't worry about structure.

 

 

There is no resource bonus from going your method because it requires additional processing to work, you can't decompile the raw functions to work in different ways.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.