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
https://forums.phpfreaks.com/topic/93241-singleton-class/
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
https://forums.phpfreaks.com/topic/93241-singleton-class/#findComment-477629
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.